Keystroke Message Flags
parameter of a keystroke message contains additional information about the
keystroke that generated the message. This information includes the repeat count,
the scan code, the extended-key flag, the context code, the previous key-state
flag, and the transition-state flag. The following illustration shows the
locations of these flags and values in the lParam
An application can use the following values to manipulate the keystroke flags:
||Manipulates the ALT key flag, which indicated if the ALT key is pressed.
||Manipulates the dialog mode flag, which indicates whether a dialog box is
||Manipulates the extended key flag.
||Manipulates the menu mode flag, which indicates whether a menu is active.
||Manipulates the repeat count.
||Manipulates the transition state flag.
You can check the repeat count to determine whether a keystroke message
represents more than one keystroke. The system increments the count when the keyboard
messages faster than an application can process them. This often occurs when
the user holds down a key long enough to start the keyboard's automatic repeat
feature. Instead of filling the system message queue with the resulting
key-down messages, the system combines the messages into a single key down message and
increments the repeat count. Releasing a key cannot start the automatic repeat
feature, so the repeat count for WM_KEYUP
messages is always set to 1.
The scan code is the value that the keyboard hardware generates when the user
presses a key. It is a device-dependent value that identifies the key pressed,
as opposed to the character represented by the key. An application typically
ignores scan codes. Instead, it uses the device-independent virtual-key codes to
interpret keystroke messages.
The extended-key flag indicates whether the keystroke message originated from
one of the additional keys on the enhanced keyboard. The extended keys consist
of the ALT and CTRL keys on the right-hand side of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN and arrow keys in the clusters to the left of the numeric keypad; the NUM LOCK key; the BREAK (CTRL+PAUSE) key; the PRINT SCRN key; and the divide (/) and ENTER keys in the numeric keypad. The extended-key flag is set if the key is an
The context code indicates whether the ALT key was down when the keystroke message was generated. The code is 1 if the ALT key was down and 0 if it was up.
Previous Key-State Flag
The previous key-state flag indicates whether the key that generated the
keystroke message was previously up or down. It is 1 if the key was previously down
and 0 if the key was previously up. You can use this flag to identify keystroke
messages generated by the keyboard's automatic repeat feature. This flag is
set to 1 for WM_KEYDOWN
keystroke messages generated by the automatic repeat feature. It is always
set to 0 for WM_KEYUP
The transition-state flag indicates whether pressing a key or releasing a key
generated the keystroke message. This flag is always set to 0 for WM_KEYDOWN
messages; it is always set to 1 for WM_KEYUP
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages
- Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database