KEY_EVENT_RECORD

typedef struct _KEY_EVENT_RECORD { /* ker */

BOOL bKeyDown;

WORD wRepeatCount;

WORD wVirtualKeyCode;

WORD wVirtualScanCode;

union {

WCHAR UnicodeChar;

CHAR AsciiChar;

} uChar;

DWORD dwControlKeyState;

} KEY_EVENT_RECORD, *PKEY_EVENT_RECORD;

The KEY_EVENT_RECORD structure is used to report keyboard input events in a console INPUT_RECORD structure.

Members

bKeyDown

Specifies TRUE if the key is being pressed, FALSE if released.

wRepeatCount

Specifies a count indicating that a key is being held down. For example, when a key is held down, you might get 5 events with wRepeatCount=1, or 1 event with wRepeatCount=5, or multiple events with wRepeatCount>=1.

wVirtualKeyCode

Specifies the virtual key code that identifies the given key in a device-independent manner.

wVirtualScanCode

Specifies the virtual scan code of the given key that represents the device-dependent value generated by the keyboard hardware.

uChar

Specifies the translated UNICODE or ASCII character depending on whether the wide-character (Unicode) or ANSI version of the function was used.

dwControlKeyState

Indicates the state of the control keys. Key state flags are:

Value Meaning

RIGHT_ALT_PRESSED The Alt key is pressed.
LEFT_ALT_PRESSED The Alt key is pressed.
RIGHT_CTRL_PRESSED The Ctrl key is pressed.
LEFT_CTRL_PRESSED The Ctrl key is pressed.
SHIFT_PRESSED The Shift key is pressed.
NUMLOCK_ON The NumLock light is on.
SCROLLLOCK_ON The ScrollLock light is on.
CAPSLOCK_ON The CapsLock light is on.
ENHANCED_KEY The key is enhanced.

Comments

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.

Key events are generated when any key, including control keys, is pressed or released. 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 (ENABLE_PROCESSED_INPUT).

See Also

INPUT_RECORD, ReadConsoleInput