1

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.

cbr
  • 12,563
  • 3
  • 38
  • 63
Scott Chambers
  • 581
  • 6
  • 22

1 Answers1

0

It seems that Android Emulator will not forward this key to the application, just like e.g. the function keys. Receiving these key events on a real device from a real keyboard works fine for me.

PHolzwarth
  • 327
  • 1
  • 5