Game Development Reference
In-Depth Information
'
It seems that I can
t count on the repeat value as shown here. It is completely depen-
dent on your equipment manufacturer and keyboard driver software. You may get
repeat values and you may not. You need to make sure your code will work either
way.
For the next sequence, I held the left Shift key and typed the same original sequence
12ab:
WM_KEYDOWN
Code:16
'
_
'
Repeat:1 Oem:42 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYDOWN
Code:16
'
_
'
Repeat:1 Oem:42 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:16
'
_
'
Repeat:1 Oem:42 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:16
'
_
'
Repeat:1 Oem:42 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:16
'
_
'
Repeat:1 Oem:42 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:49
'
1
'
Repeat:1 Oem: 2 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_CHAR
Code:33
'
!
'
Repeat:1 Oem: 2 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYUP
Code:49
'
1
'
Repeat:1 Oem: 2 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:50
'
2
'
Repeat:1 Oem: 3 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_CHAR
Code:64
'
@
'
Repeat:1 Oem: 3 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYUP
Code:50
'
2
'
Repeat:1 Oem: 3 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:65
'
A
'
Repeat:1 Oem:30 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_CHAR
Code:65
'
A
'
Repeat:1 Oem:30 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYUP
Code:65
'
A
'
Repeat:1 Oem:30 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:66
'
B
'
Repeat:1 Oem:48 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_CHAR
Code:66
'
B
'
Repeat:1 Oem:48 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYUP
Code:66
'
B
'
Repeat:1 Oem:48 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYUP
Code:16
'
_
'
Repeat:1 Oem:42 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
'
There
s nothing too surprising here; the Shift key will repeat until the next key is
pressed. Note that the repeats on the Shift key don ' t continue. Just as in the first
sequence, only the WM_CHAR message gives you your expected character.
You should realize by now that if you want to use keys on the keyboard for hot keys,
you can use the WM_KEYDOWN message and you won
t have to care if the Shift key (or
even the Caps Lock key) is pressed. Pressing the Caps Lock key gives you this output:
'
WM_KEYDOWN Code: 20
'
_
'
Repeat:1 Oem:58 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYUP
Code: 20
'
_
'
Repeat:1 Oem:58 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
The messages that come through for WM_CHAR will operate as if the Shift key were
pressed down.
Let
'
s try some function keys, including F1, F2, F3, and the shifted versions also:
WM_KEYDOWN
Code:112
'
p
'
Repeat:1 Oem:59 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
WM_KEYUP
Code:112
'
p
'
Repeat:1 Oem:59 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:1
WM_KEYDOWN
Code:113
'
q
'
Repeat:1 Oem:60 Ext
'
d:0 IsAlt:0 WasDown:0 Rel
'
d:0
Search WWH ::




Custom Search