I'm currently working on a practice program that works with various keyboard inputs so I can understand how they work in Android apps with Java. But I am struggling to get the ESC
key to be recognised. The code below doesn't work. Has anyone ever managed to get the ESC
key to work in an app? Is it actually possible?
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
boolean handled = false;
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
textView.setText("Escapekey pressed");
handled = true;
}
return handled;
}
});
To summarize, I want the program to recognise the ESC
key.