Detect when Done key is pressed

If you want to detect when a key from soft keyboard is pressed, like Done key, you can use the following code:

mEditText = (EditText)findViewById(;

mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

                //verifies what key is pressed, in our case verifies if the DONE key is pressed
                if (actionId == EditorInfo.IME_ACTION_DONE) {

                    //put your code here

                return false;
Exit mobile version