GetAsyncKeyState (Windows Embedded CE 6.0)
1/6/2010
This function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
Syntax
SHORT GetAsyncKeyState(
int vKey
);
Parameters
vKey
[in] Specifies one of 256 possible virtual-key codes. For more information, see Translating Scan Codes to Virtual-Key Codes.You can use left- and right-distinguishing constants to specify certain keys. For more information about constants, see Remarks.
Return Value
If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down. The least significant bit is not valid in Windows Embedded CE, and should be ignored. GetAsyncKeyState returns the current key state even if a window in another thread or process currently has the keyboard focus.
Remarks
You can use the VK_LBUTTON virtual-key code constant to determine whether the stylus tip is touching the screen or not.
The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling
GetSystemMetrics(SM_SWAPBUTTON)
which returns TRUE if the mouse buttons have been swapped.
You can use the virtual-key code constants VK_SHIFT, VK_CONTROL, and VK_MENU as values for the vKey parameter. This gives the state of the SHIFT, CTRL, or ALT keys without distinguishing between left and right.
You can use the following virtual-key code constants as values for vKey to distinguish between the left and right instances of those keys.
VK_LSHIFT |
VK_RSHIFT |
VK_LCONTROL |
VK_RCONTROL |
VK_LMENU |
VK_RMENU |
These left- and right-distinguishing constants are only available when you call the GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
Requirements
Header | winuser.h |
Library | Kbdui.lib |
Windows Embedded CE | Windows CE 1.0 and later |
See Also
Reference
Keyboard Functions
GetKeyState
MapVirtualKey