17.3.9 Key Events

Key events are generated when any key, including control keys, is pressed. However, Alt when pressed and released without combining with another character has special meaning to Windows and is not passed through to the application. Also, Ctrl-C is not passed through if the input handle is in processed mode. If the event is a keystroke, the Event field of the input record will be a key event record with the following fields:

bKeyDown TRUE if key is being pressed; FALSE if key was released
wVirtualKeyCode The virtual key code that identifies the given key in a device-independent manner.
wVirtualScanCode The virtual scan code that represents the value generated by the keyboard hardware for the given key. This value indicates in a device-dependent manner the identity of the physical key pressed.
uChar The translation of the key into either an ASCII or Unicode character. The translation depends on whether the wide-character (Unicode) or ANSI version of the function was used
dwControlKeyState A flag indicating the state of the control keys (Alt, Ctrl, Shift, Num Lock, Scroll Lock, Caps Lock). Constants defined in WINCON.H can be ANDed with this flag to determine if specific control keys were pressed. The flag also indicates if the pressed key was one of the keys on an enhanced keyboard, in which case, the specific key can be determined from the virtual key code. Enhanced keys for the IBM 101- and 102-key keyboards are: the insert, delete, home, end, page up, page down, and direction keys in the clusters to the left of the numeric key pad; and the divide (/) and ENTER keys in the numeric key pad.