int GetKeyState(vkey) | |||||
int vkey; | /* virtual key | */ |
The GetKeyState function retrieves the state of the specified virtual key. The state specifies whether the key is up, down, or toggled (on, off—alternating each time the key is pressed).
vkey
Specifies a virtual key. If the requested virtual key is a letter or digit (A through Z, a through z, or 0 through 9), vkey must be set to the ASCII value of that character. For other keys, it must be a virtual-key code. For a list of virtual-key codes, see the Microsoft Windows Programmer's Reference, Volume 3.
The return value specifies the state of the given virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the low-order bit is 1, the key is toggled. A toggle key, such as the CAPSLOCK key, is toggled if it has been pressed an odd number of times since the system was started. The key is untoggled if the low-order bit is 0.
An application calls the GetKeyState function in response to a keyboard-input message. This function retrieves the state of the key at the time the input message was generated.