Bug 678

Summary: NEWT KeyEvent key-char value on Windows not delivered w/ PRESSED induces UI lag if depending on key-char value
Product: [JogAmp] Newt Reporter: Sven Gothel <sgothel>
Component: windowsAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: enhancement CC: damichl73, gouessej
Priority: ---    
Version: 1   
Hardware: All   
OS: all   
Type: --- SCM Refs:
jogl 90e136b65a10d8daf8c3a2df6cc193e55a63722c jogl 85338858f5c58694fa88e77df1386d0556887944 jogl 4898f582d9303caa7fd1b44438808e86b51c2a3b
Workaround: ---
Bug Depends on:    
Bug Blocks: 688    

Description Sven Gothel 2013-01-29 13:09:10 CET
http://forum.jogamp.org/Newt-KeyEvent-typed-only-produced-on-key-up-and-auto-repeat-tp4028032.html

This is a know issue and documented in NEWT's KeyEvent getKeyChar() (-> DISCLAIMER).

Analysis:

  NEWT delivery order: 
      PRESSED (t0), RELEASED (t1) and TYPED (t1)

  WINDOWS delivery order: 
      PRESSED (t0), TYPED (t0) and RELEASED (t1)
  Windows Auto-Repeat:
      PRESSED (t0), TYPED (t0)


It has been observed that the even though the WINDOWS delivery order is 'rotated',
we Windows PRESSED and TYPED events are incoming at (almost) the same time,
i.e. beyond measurement accuracy.

Hence we could change the event reorder code in NEWT to trigger on TYPED
and use it's valid key-char value.
Comment 1 Julien Gouesse 2013-01-29 14:56:14 CET
It would be fine to keep this order consistent across platforms (if possible) instead of risking to break it all to favor Windows support.
Comment 2 Sven Gothel 2013-01-29 21:18:41 CET
(In reply to comment #1)
> It would be fine to keep this order consistent across platforms (if possible)
> instead of risking to break it all to favor Windows support.

Order is and will be consistent, just adapting to the fact that on Windows
PRESSED and TYPED arrive at the 'same' time (hence both @ t0).
So we can use TYPED for printable chars as the event trigger
and have the key-char value consistent for all platforms for all KeyEventListener callbacks.
Comment 4 Sven Gothel 2013-02-15 14:27:39 CET
regression w/ modifier keys .. 

need to properly deduce UTF-16 char value @ key PRESS/RELEASE to produce
all events. 

May related to Bug 688, i.e. allows removal of TYPED event.
Comment 6 cubus 2013-03-08 03:26:54 CET
jogl 2.0 rc-11
windows vista 32 bit
java 1.6.0_39
german keyboard (qwertz)

in keyTyped(), KeyEvent.getKeyChar() returns invalid values for the 'ß' key.

problem 1
---------
'ß'         -> 'ß' (OK)
'ß' + SHIFT -> 'ß' (SHOULD BE '?')
'ß' + ALTGR -> 'ß' (SHOULD BE '\')

problem 2
---------
the first time 'ß' gets typed after application startup:
KeyEvent.getKeyEvent() returns 0
KeyEvent.getKeyChar() returns 65535

problem 3
---------
when typing 'ß' + ALTGR:
KeyEvent.isAltGraphDown() returns false, but
KeyEvent.isAltDown() AND KeyEvent.isAltControlDown() both return true.
Comment 7 Sven Gothel 2013-04-06 05:00:50 CEST
(In reply to comment #6)
> jogl 2.0 rc-11
> windows vista 32 bit
> java 1.6.0_39
> german keyboard (qwertz)
> 
> in keyTyped(), KeyEvent.getKeyChar() returns invalid values for the 'ß' key.
> 
> problem 1
> ---------
> 'ß'         -> 'ß' (OK)
> 'ß' + SHIFT -> 'ß' (SHOULD BE '?')
> 'ß' + ALTGR -> 'ß' (SHOULD BE '\')
> 
> problem 2
> ---------
> the first time 'ß' gets typed after application startup:
> KeyEvent.getKeyEvent() returns 0
> KeyEvent.getKeyChar() returns 65535

'ß':
  KeyEvent[EVENT_KEY_PRESSED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [],
  KeyEvent[EVENT_KEY_RELEASED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [],
  KeyEvent[EVENT_KEY_TYPED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [],

 - code 0x2d == VK_MINUS  -> OK
 - sym 0x5b == VK_OPEN_BRACKET -> ERR, Win7 mapped it here to VK_OEM_4  '[{' key .. only valid for US *** ERROR ***

> 
> problem 3
> ---------
> when typing 'ß' + ALTGR:
> KeyEvent.isAltGraphDown() returns false, but
> KeyEvent.isAltDown() AND KeyEvent.isAltControlDown() both return true.

Fixed ALTGR w/ commit4898f582d9303caa7fd1b44438808e86b51c2a3b , 
however, CTRL is down w/ German KBD and I dunno why.

ALT + 'ß':
  KeyEvent[EVENT_KEY_PRESSED, code 0x12, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_PRESSED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_RELEASED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_TYPED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_RELEASED, code 0x12, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [alt],


'ß' + ALT:
  KeyEvent[EVENT_KEY_PRESSED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [],
  KeyEvent[EVENT_KEY_PRESSED, code 0x12, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_RELEASED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_TYPED, code 0x2d, sym 0x5b, char '�' (0xdf), isModifierKey false, isActionKey false, InputEvent[modifiers: [alt],
  KeyEvent[EVENT_KEY_RELEASED, code 0x12, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [alt],

ALTGR:
  KeyEvent[EVENT_KEY_PRESSED, code 0x11, sym 0x11, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [ctrl],
  KeyEvent[EVENT_KEY_PRESSED, code 0xff7e, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_RELEASED, code 0x11, sym 0x11, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_RELEASED, code 0xff7e, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [altgr],

ALTGR + 'ß':
  KeyEvent[EVENT_KEY_PRESSED, code 0x11, sym 0x11, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [ctrl],
  KeyEvent[EVENT_KEY_PRESSED, code 0xff7e, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_PRESSED, code 0x2d, sym 0x5b, char '\' (0x5c), isModifierKey false, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_RELEASED, code 0x2d, sym 0x5b, char '\' (0x5c), isModifierKey false, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_TYPED, code 0x2d, sym 0x5b, char '\' (0x5c), isModifierKey false, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_RELEASED, code 0x11, sym 0x11, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [ctrl, altgr],
  KeyEvent[EVENT_KEY_RELEASED, code 0xff7e, sym 0x12, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [altgr],

SHIFT + 'ß':
  KeyEvent[EVENT_KEY_PRESSED, code 0x10, sym 0x10, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [shift],
  KeyEvent[EVENT_KEY_PRESSED, code 0x2d, sym 0x5b, char '?' (0x3f), isModifierKey false, isActionKey false, InputEvent[modifiers: [shift],
  KeyEvent[EVENT_KEY_RELEASED, code 0x2d, sym 0x5b, char '?' (0x3f), isModifierKey false, isActionKey false, InputEvent[modifiers: [shift],
  KeyEvent[EVENT_KEY_TYPED, code 0x2d, sym 0x5b, char '?' (0x3f), isModifierKey false, isActionKey false, InputEvent[modifiers: [shift],
  KeyEvent[EVENT_KEY_RELEASED, code 0x10, sym 0x10, char '' (0x0), isModifierKey true, isActionKey false, InputEvent[modifiers: [shift],