microsoft / node-native-keymap

Provide OS keyboard layout functionality as a nodejs module
MIT License
136 stars 37 forks source link

Use different method to get key label in the no modifiers case #1

Closed alexdima closed 8 years ago

alexdima commented 8 years ago

Currently, for German (Swiss) the value for VKEY_OEM_5 is:

  { key_code: 'VKEY_OEM_5',
    value: '´ä',
    withShift: 'à',
    withAltGr: '{',
    withShiftAltGr: '' },

Try to make it ä instead of ´ä

alexdima commented 8 years ago

See Microsoft/vscode#1358

the-ress commented 8 years ago

The issue is actually caused by calling ToUnicode for AltGr+VKEY_OEM_4 before calling it for VKEY_OEM_5. The first call inserts the dead character into the buffer and then the call for VKEY_OEM_5 returns both characters.

As described in ToUnicodeEx documentation:

As ToUnicodeEx translates the virtual-key code, it also changes the state of the kernel-mode keyboard buffer. This state-change affects dead keys, ligatures, alt+numpad key entry, and so on.

The fix in 966f8cf only defers the issue to the next character:

  { key_code: 'VKEY_OEM_5',
    value: 'ä',
    withShift: '´à',
    withAltGr: '{',
    withShiftAltGr: '' },

This issue affects Czech Programmers layout too.