1

I am trying to listen for arrow key (dpad) presses in an EditText, on a softkey keyboard. I've tried multiple approaches, but nothing has triggered the key event to be sent to any listener or overridden method when the arrow keys are pressed. The backspace key works, but many other keys do not, including the ones I want.

What I have tried so far:

  • editText.setOnKeyListener
  • editText.setKeyListener
  • new editText() { @Override onKeyDown() }
Ed Marty
  • 39,590
  • 19
  • 103
  • 156

2 Answers2

0

There is a solution answering another SO question, though it may be kludgy, it will work. THeir solution is to handle lost focus of EditView.

link

Community
  • 1
  • 1
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
  • The problem is that focus is never lost when pressing the D-Pad. There are no other controls for focus to move to. Unless you are suggesting I make some invisible controls... but that's definitely more kludgy than I'm looking for. – Ed Marty May 01 '13 at 14:11
0

Here's a shot in the dark, maybe KeyEvent.KEYCODE_DPAD_LEFT or one of the other constants in the KeyEvent class? You could try checking for each arrow event in an OnEditorActionListener, like in this other SO question: https://stackoverflow.com/a/5077543/475217

Community
  • 1
  • 1
Ben Jakuben
  • 3,147
  • 11
  • 62
  • 104
  • The constants are what I'm checking for. And the action listener isn't being called either, unfortunately (which I am already using for listening to the enter key). – Ed Marty May 01 '13 at 14:10