[SOLVED] Some Keys not Registering KeyInputEvent on Android

Testing out my TextField on Android has yielded an interesting result. While bringing up the soft keyboard and typing generally works, the backspace key and none of the number keys work. In regards to numbers these do not work when long-pressing a letter key to bring up a selection and selecting a number, neither do they work when switching to the number/symbol keypad.

I added in System.out.println(evt.getKeyCode() + ":" + evt.getKeyChar()); to the KeyListener to see if there was any output and the listener is not called when any of the keys in question are pressed.

P.S. For the record most of the rarely used symbol keys don’t work either, like the copyright symbol and degrees symbol, but who uses those in a game anyway?

I’ve tracked down the bug and it seems to be because android an android issue. It is recognizing characters as if it were a ā€œgame padā€. However, for the backspace and others it doesn’t seem to recognize any device, so jme’s AndroidInputHandler discard the event. I fixed it assuming that if the device is not recognized and the soft-keyboard is open then it must be a touch-input event.

I’m not sure if this is the best way but it now recognizes all keys.

3 Likes

Had to encounter this bug once a long time ago, hope it is finally fixed.

I have to report that on Android Jellybean numbers are working, but backspace is still not.

You made sure that the fix was in place when you tried it?, I’ll try it later myself (I need it working :sweat_smile:)

I used ā€˜-SNAPSHOT’ from jitpack: JitPack | Publish JVM and Android libraries
It should include all relatively recent pull requests.

I’ve tried it in Marshmallow (6.0) and KitKat (4.4) and it works fine. I can’t currently try it with jellybean because of the emulator has an old play-services (which can’t be easily upgraded on those emulators) and my game relies on a much newer one.
I have a bad experience using the ā€˜-SNAPSHOT’ with jitpack (it didn’t download always the latest commits, even with the ā€œforceā€ recommendation. However, I just downloaded the latest jme version and built it (./gradlew build).

1 Like