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.
答案 0 :(得分:0)
Android Emulator 似乎不会将此密钥转发给应用程序,就像例如功能键。在真实设备上通过真实键盘接收这些按键事件对我来说效果很好。