I have an EditText with android:inputType="phone" keybord. There is an "OK" on this keyboard. I like to catch pressing this OK btn. However I don’t know the key event. I would like to use code like this:
setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.?????????? <- this one please
return true;
default:
break;
}
}
return false;
}
});
I hope the code is different from pressing the “round-arrow”!
I checked all the key events in the docs but could not find anything.
Thanks
The ‘OK’ button is usually associated with finishing the input, and is different from the others. Use
setOnEditorActionListenerto catch it: