void GetKeyboardState(lpbKeyState) | |||||
BYTE FAR* lpbKeyState; | /* address of array to receive virtual-key codes | */ |
The GetKeyboardState function copies the status of the 256 virtual-keyboard keys to the specified buffer.
lpbKeyState
Points to the 256-byte buffer that will receive the virtual-key codes.
This function does not return a value.
An application calls the GetKeyboardState function in response to a keyboard-input message. This function retrieves the state of the keyboard at the time the input message was generated.
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.
For a list of virtual-key codes and their corresponding mouse or keyboard equivalents, see the Microsoft Windows Programmer's Reference, Volume 3.
The following example simulates a pressed CTRL key:
BYTE pbKeyState[256];
GetKeyboardState((LPBYTE) &pbKeyState);
pbKeyState[VK_CONTROL] |= 0x80;
SetKeyboardState((LPBYTE) &pbKeyState);