Jump to content
  • Advertisement
Sign in to follow this  
JohnRaptis

Getting keypresses from Keyboard

This topic is 2228 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement

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?

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!