1

In my application I want to get user input with whatever their default soft input is, but I'm not using any input areas. I've already popped up the soft input, but now I need to listen to the keyboard events from that soft input.

I assumed this would be a solved problem but I'm having trouble with the documentation. I want to get what user's soft input generates in my application, even when there's no input field with focus.

Is this phrased clearly enough?

Cheers.

Heath Hunnicutt
  • 18,667
  • 3
  • 39
  • 62
  • Please check my answer on the http://stackoverflow.com/questions/4171234/androidhow-to-get-any-keypress-event-with-example/4171427#4171427. Is that what you were looking for? – Zelimir Mar 28 '11 at 06:36

2 Answers2

0

Hi there goodaccountname,

I think the better way is to add a hidden textview and request a focus on it after opening the keyboard and use textwatcher (http://developer.android.com/reference/android/text/TextWatcher.html) to listen to every change in the text. That's all. I did not try this but these will help. Good day!

donmj
  • 379
  • 7
  • 13
0

After opening the soft input with InputManager#showSoftInput(View view,int flags) you have to set yourself as OnKeyListener of this view and you will receive all key events.

tbolender
  • 1,172
  • 3
  • 14
  • 19
  • OnKeyListener is for hardware keys. Taps on the keys on a soft keyboard don't come through here. – Eliot Jul 24 '17 at 13:28