Dirk Hoffmann
12/10/2021, 1:56 PMBasicTextField I want to trigger some stuff on pressing Ctrl-Space:
modifier.onPreviewKeyEvent {
val awtKeyEvent = it.nativeKeyEvent as java.awt.event.KeyEvent
println(it)
println(awtKeyEvent)
...
on pressing Ctrl-Space the KeyEvents for the Space char never come along, only for the Ctrl key ... but not the space key:
KeyEvent(nativeKeyEvent=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=17,keyText=⌃,keyChar=Undefined keyChar,modifiers=⌃,extModifiers=⌃,keyLocation=KEY_LOCATION_LEFT,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x11] on canvas0)
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=17,keyText=⌃,keyChar=Undefined keyChar,modifiers=⌃,extModifiers=⌃,keyLocation=KEY_LOCATION_LEFT,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x11] on canvas0
KeyEvent(nativeKeyEvent=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=17,keyText=⌃,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_LEFT,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x11] on canvas0)
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=17,keyText=⌃,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_LEFT,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x11] on canvas0
compared to pressing Alt-Space where also Key Events for the space char DO come along. e.g.:
KeyEvent(nativeKeyEvent=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=␣,keyChar=' ',modifiers=⌥,extModifiers=⌥,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0] on canvas0)
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=␣,keyChar=' ',modifiers=⌥,extModifiers=⌥,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0] on canvas0
KeyEvent(nativeKeyEvent=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=' ',modifiers=⌥,extModifiers=⌥,keyLocation=KEY_LOCATION_UNKNOWN,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0] on canvas0)
Why Ctrl-Space events for the Space key do not come along, but Alt-Space space key does??