Android detect Done key press for OnScreen Keyboard

Yes, it is possible:

editText = (EditText) findViewById(R.id.edit_text);

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            // do your stuff here
        }
        return false;
    }
});

Note that you will have to import the following libraries:

import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;

Leave a Comment