get_keyboard_state


bool get_keyboard_state(byte* state)

This function obtains the status of the 256 virtual keys of the keyboard.

Parameters

byte* state

A pointer to an array of 256 bytes that is updated to contain the status of each virtual key.

Return

bool

true The function succeeded.
false The call failed.

Notes

This function obtains the current status of all virtual keys. As keyboard messages are removed from a thread's message queue, the status of the virtual keys changes.

The status of keys does not change:

Upon return, each element of the array contains the status data of a virtual key. If the high-order bit is set, the key is down and it is up when the bit is clear. If the low-order bit is 1, the key is toggled. A key (for example the caps lock key) is toggled when it is turned on. The key is off and untoggled if the low-order bit is 0. An indicator light associated with a toggle key is on when the key is toggled and off when the key is untoggled.

The function get_key_state may be used to obtain status information of an individual key. The function get_asynchronous_key_state obtains the status information of an individual key independent of the state of message queue input.

The virtual-key code constants:

may be used as indices into the given array. These indices yield the status of the shift, ctrl and alt keys without distinguishing between left and right. The following virtual key code constants may be used as indices to distinguish between the left and right occurrences of these keys.

virtual_key::left_shift virtual_key::right_shift
virtual_key::left_control virtual_key::right_control
virtual_key::left_menu virtual_key::right_menu

These left and right distinguishing constants are available only through the functions