====== KEYSTATE property (System) ====== ==== Description ==== This property returns: 1. The state of a key at the time the last message was read from the Presentation Server’s message queue (the key to check is passed as a virtual-key code in the index parameter), or 2. An array representing the state of all virtual keys if no virtual key code is passed. ==== Property Value ==== If a virtual-key code was specified this property is an integer value that represents a set of bit flags. As a general rule: • If the key is pressed down the property returns a value < 0 (i.e. The most significant bit is set), otherwise the key is not pressed. • If the key is toggled (such as the CAPS-LOCK key) then the least significant bit is set (this only applies to keys that can be toggled) If a virtual-key code was not specified this property returns an @fm-delimited array of flags for all virtual keys (this is a 256-element array) – the meaning of the flags is as described above. See remarks for more information. ==== Property Traits ==== ^Development^Runtime^Indexed^Scaled^Synthetic^ |N/A|Get|Yes|No|No| ==== Remarks ==== This property is essentially a wrapper around the GetKeyState and GetKeyboardState Windows API functions, so please refer to the documentation on the Microsoft website for further information. Virtual-key code constants are defined in the MSWin_VirtualKey_Equates insert record. ==== Example ==== $Insert msWin_VirtualKey_Equates // Get the state of the Shift key ShiftDown = ( Get_Property( "SYSTEM", "KEYSTATE", VK_SHIFT$ ) < 0 ) // Get the state of the CAPS-LOCK key CapState = Get_Property( "SYSTEM", "KEYSTATE", VK_CAPITAL$ ) CapPressed = ( CapState < 0 ) CapToggled = BitAnd( CapState, 0x01 ) // Get the state of all keys and extract the CAPS-LOCK state KeyboardState = Get_Property( "SYSTEM", "KEYSTATE" ) CapState = KeyboardState ==== See Also ==== ASYNCKEYSTATE property