key (keyboard press/release) events never arrive
ddyer0 opened this issue · comments
This trace is from the simulator, but I see the same thing in windows-on-android where the physical
keyboard is somehow arriving in the input stream of the android app. I've also seen this with bluetooth
keyboards attached to a real android device.
Here, I typed "qwerty" with the first three keystrokes in the normal, very fast sequence.
Note that the first "up" even is 119, there's never an up event for "q" or "e"
E 22+381.657 KeyEvent 113(0x71)null true // q down
E 22+457.573 KeyEvent 119(0x77)null true // w down
E 22+546.410 KeyEvent 101(0x65)null true // e down
E 22+669.893 KeyEvent 119(0x77)null false // w up
E 23+5.395 KeyEvent 114(0x72)null true // r down
E 23+103.259 KeyEvent 114(0x72)null false // r up
E 23+300.825 KeyEvent 116(0x74)null true // t down
E 23+386.313 KeyEvent 116(0x74)null false // t up
E 23+532.205 KeyEvent 121(0x79)null true // y down
E 23+593.040 KeyEvent 121(0x79)null false // y up
Also, the non alphanumeric keys arrive strangely, or not at all.
E 5+491.973 KeyEvent -23453(0x63)null true // backspace
E 9+300.439 KeyEvent 0(0x0)null true //del
//enter doesn't arrive
// tab sometimes arrives
// control-anything doesn't arrive
I found part of an explanation and workaround, using Display.setMultiKeyMode(true).
It's not completely clear why this is off by default, and it doesn't seem right that it
bypasses the keyup function, leaving keydown/keyup unbalanced.
Ordinary typing always involves overlap between the up/down events.
Anyway, this explains/fixes some of the anomalies in the simulator, but doesn't help at all
with the class of non-printing characters being unavailable on real devices.
The latter are probably mapped to the gamekey API. These APIs were designed in an era of feature phones.
See these about the multikey mode:
CodenameOne/CodenameOne/src/com/codename1/ui/Display.java
Lines 1998 to 2004 in 51c99bb
CodenameOne/CodenameOne/src/com/codename1/ui/Display.java
Lines 4775 to 4783 in 51c99bb