KeyPress Event
2006-06Jun-02
Qualifier keys such as ALT, CTRL and SHIFT are prioritized in this order. When the user presses a combination of these three keys, the highest qualifier determines the key code. If, for instance, the ALT key is pressed with SHIFT, the key code is the same as if you pressed the key and just ALT. If the user instead presses SHIFT and CTRL, the key code switches to the CTRL combination. Only when the SHIFT key is pressed, you would end up with the SHIFT key code. The following table clarifies this for the U key:
nKeyCode nShiftAltCtrlU 117 0Shift+U 85 1Ctrl+U 21 2Alt+U 22 4Shift+Ctrl+U 21 3Shift+Alt+U 22 5Ctrl+Alt+U 22 6Shift+Alt+Ctrl+U 22 7 (works only intermittently on my laptop)The exception from the rule above is the SHIFT+ALT combination on keyboards that support anALTGR key. SHIFT+ALT+Key and ALTGR+Key trigger the KeyPress event with nShiftAltCtrl=0 and the regular key code.
This is the same side
effect that occurs with ON KEY LABEL and with certain key combination to control
child windows such as ALT+hypen (ALT+-) on a US keyboard which requires a German
user to press ALT+ß.
Some special keys fire the KeyPress event, as well:
Some codes are identical. However, this doesn't necessarily apply to all qualifier key combinations.
The following combination do not work in conjunction with Ctrl or Ctrl+Shift. The first label is
the corresponding key on a German keyboard, the second value on a US keyboard
SHIFT+F10 is the context menu key and therefore returns nKeyCode=93 and nShiftAltCtrl=1.
With CapsLock, the key codes are inverted.
effect that occurs with ON KEY LABEL and with certain key combination to control
child windows such as ALT+hypen (ALT+-) on a US keyboard which requires a German
user to press ALT+ß.
Some special keys fire the KeyPress event, as well:
nKeyCode | nShiftAltCtrl | |
Caps Lock+Shift+Alt | 58 | 6 (not reliable) |
57 | 5 (not reliable) | |
Ctrl+Win+Alt | 91 | 7 |
Shift+Alt+0 | 11 | 5 |
Some codes are identical. However, this doesn't necessarily apply to all qualifier key combinations.
nKeyCode | nShiftAltCtrl | |
Ctrl++ / Ctrl+Pos1 | 29 | 2 |
Ctrl+H / Ctrl+Del | 127 | 2 |
Ctrl+W / Ctrl+End | 23 | 2 |
Ctrl+Left Arrow / Ctrl+Z | 26 | 2 |
Ctrl+Right Arrow / Ctrl+B | 2 | 2 |
Alt+0 / Alt+R | 19 | 4 |
Shift+Alt+0 | 19 | 5 |
Ctrl+J / Ctrl+Enter | 10 | 3 |
Shift+Ctrl+J | 10 | 3 |
Shift+Z / Shift+F7 | 90 | 1 |
Shift+T / Shift+F1 | 84 | 1 |
Shift+U / Shift+F2 | 85 | 1 |
Shift+W / Shift+F4 | 87 | 1 |
Shift+Y / Shift+F6 | 89 | 1 |
Shift+X / Shift+F5 | 88 | 1 |
Shift+V / Shift+F3 | 86 | 1 |
The following combination do not work in conjunction with Ctrl or Ctrl+Shift. The first label is
the corresponding key on a German keyboard, the second value on a US keyboard
German | US |
^ | ' |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
ß | - |
' | = |
Ö | ; |
Ä | ' |
, | , |
. | . |
- | / |
SHIFT+F10 is the context menu key and therefore returns nKeyCode=93 and nShiftAltCtrl=1.
With CapsLock, the key codes are inverted.