Getting keypresses from Keyboard

Started by
2 comments, last by frob 12 years ago
Hi all,

I want to pop up the keyboard on Android, and intercept keypresses to send them to my app (which is running on another thread).

I am working in the NativeSDK, with a Java helper.

On iPhone, I do this by making an offscreen text box, then giving it focus. I'm then able to hook a function to watch the keyboard, and get the keypresses before they go to the text box.

Is there anything equivalent on Android? I can't seem to make anything work... seems like I can't even put an offscreen text box with the GL Surface View I'm using. It seems like either the GL View, or the threading is messing me up-- does anyone have a nice simple methodology for accomplishing this? Really all I want to know is the char that was pressed on the keyboard, so I can push it into my own system.

Thanks for your help!
--John
Advertisement
You can always use onKeyDown and onKeyUp events. Those two are probably the most commonly used for games.

You can always use onKeyDown and onKeyUp events. Those two are probably the most commonly used for games.


Will those work with the onscreen keyboard as well? Or are those just for phones with a keypad?
I believe it is generated for every keystroke, whether that comes from a hardware key or from an IME (software keyboard) key.

Also note that it isn't just phone keypads. Tablets can have full keyboards, some devices accept USB keyboards, and you can attach bluetooth keyboards to most devices. There are similar events for mice and pointing devices, if you are interested in those as well.

This topic is closed to new replies.

Advertisement