KEY_EVENT_RECORD

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

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; 
 

Members

bKeyDown
Specifies TRUE if the key is being pressed, FALSE if the key is being released.
wRepeatCount
Specifies a count indicating that a key is being held down. For example, when a key is held down, you might get five events with this member equal to 1, one event with this member equal to 5, or multiple events with this member greater than or equal to 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 ReadConsoleInput function was used.
dwControlKeyState
Indicates the state of the control keys. This member can be a combination of the following values:
Value Meaning
CAPSLOCK_ON The caps lock light is on.
ENHANCED_KEY The key is enhanced.
LEFT_ALT_PRESSED The left alt key is pressed.
LEFT_CTRL_PRESSED The left ctrl key is pressed.
NUMLOCK_ON The num lock light is on.
RIGHT_ALT_PRESSED The right alt key is pressed.
RIGHT_CTRL_PRESSED The right ctrl key is pressed.
SCROLLLOCK_ON The scroll lock light is on.
SHIFT_PRESSED The shift key is pressed.

Remarks

Enhanced keys for the IBM® 101- and 102-key keyboards are the ins, del, home, end, page up, page down, and direction keys in the clusters to the left of the keypad; and the divide (/) and enter keys in the keypad.

Keyboard input events are generated when any key, including control keys, is pressed or released. However, the alt key when pressed and released without combining with another character, has special meaning to the system and is not passed through to the application. Also, the ctrl+c key combination is not passed through if the input handle is in processed mode (ENABLE_PROCESSED_INPUT).

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in wincon.h.

See Also

Consoles and Character-Mode Support Overview, Console Structures, PeekConsoleInput, ReadConsoleInput, WriteConsoleInput, INPUT_RECORD