|
Overview |
|
|
|
Group |
|
|
|
Quick Info
Windows NT
| Yes
| Win95
| Yes
| Win32s
| Yes
| Import Library
| user32.lib
| Header File
| winuser.h
| Unicode
| No
| Platform Notes
| None
|
|
|
GetKeyState
The GetKeyState function retrieves the status of the specified virtual key. The status
specifies whether the key is up, down, or toggled (on, off alternating each time the key is pressed).
SHORT GetKeyState(
int nVirtKey
| // virtual-key code
| );
|
|
Parameters
nVirtKey
Specifies a virtual key. If the desired virtual key is a letter or digit (A
through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be
a virtual-key code.
If a non-English keyboard layout is used, virtual keys with values in the
range ASCII A through Z and 0 through 9 are used to specify most of the character
keys. For example, for the German keyboard layout, the virtual key of value
ASCII O (0x4F) refers to the "o" key, whereas VK_OEM_1 refers to the "o with
umlaut" key.
Return Values
If the function succeeds, the return value specifies the status of the given
virtual key. 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 key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the
low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be
on when the key is toggled, and off when the key is untoggled.
Remarks
The key status returned from this function changes as a given thread reads key
messages from its message queue. The status does not reflect the
interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.
An application calls GetKeyState in response to a keyboard-input message. This function retrieves the state of
the key when the input message was generated.
To retrieve state information for all the virtual keys, use the GetKeyboardState function.
An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL,
and VK_MENU as values for the nVirtKey parameter. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also
use the following virtual-key code constants as values for nVirtKey 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 available to an application
only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
See Also
GetAsyncKeyState, GetKeyboardState, MapVirtualKey, SetKeyboardState
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|