int GetKeyState(nVirtKey)
This function retrieves the state of the virtual key specified by the nVirtKey parameter. The state specifies whether the key is up, down, or toggled.
Parameter | Type/Description | |
nVirtKey | int Specifies a virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be one of the values listed in the Appendix, “Virtual-Key Codes.” |
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 bit is 0.
An application calls the GetKeyState function in response to a keyboard-input message. This function retrieves the state of the key when the input message was generated.