Sign in to follow this  
JohnRaptis

Getting keypresses from Keyboard

Recommended Posts

JohnRaptis    188
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

Share this post


Link to post
Share on other sites
JohnRaptis    188
[quote name='frob' timestamp='1334764800' post='4932503']
You can always use onKeyDown and onKeyUp events. Those two are probably the most commonly used for games.
[/quote]

Will those work with the onscreen keyboard as well? Or are those just for phones with a keypad?

Share this post


Link to post
Share on other sites
frob    44911
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this