GetKeyboardState

Syntax

void GetKeyboardState(lpKeyState)

This function copies the status of the 256 virtual-keyboard keys to the buffer specified by the lpKeyState parameter. The high bit of each byte is set to 1 if the key is down, or it is set to 0 if it is up. The low bit is set to 1 if the key was pressed an odd number of times since startup. Otherwise, it is set to 0.

Parameter Type/Description  
lpKeyState BYTE FAR * Points to the 256-byte buffer of virtual-key codes.  

Return Value

None.

Comments

An application calls the GetKeyboardState function in response to a keyboard-input message. This function retrieves the state of the keyboard when the input message was generated.

To obtain state information for individual keys, follow these steps:

1.Create an array of characters that is 265 bytes long.

2.Copy the contents of the buffer pointed to by the lpKeyState parameter into the array.

3.Use the virtual-key code from the Appendix, “Virtual-Key Codes,” to obtain an individual key state.