Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK


» Windows API reference
» Webcam streaming in VB.NET
» Remoting with firewalls
» RSA from first principles
» Key & MouseLogger in .NET
» Networking Resource Kit for .NET
» Migrating VB6 Winsock to VB.NET
» Migrating C++ sockets to C#
» RFC Reference guide
» COM Reference guide
» WMI Reference guide
» SQL stored procedures
» TCP & UDP port reference
» NET Framework reference
» Ethernet Type codes
» MAC address assignments
» DLL entry point reference
» Boost SQL performance
» Free SMS UK
» Free SMS Ireland
» Free SMS South Africa
» Internet Explorer

Contact us

GetAsyncKeyState Reference in C#, VB.NET and VB6


Visual Basic 6 definition
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer

Visual Basic .NET definition
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short

C# definition
[DllImport("user32")] public static extern short GetAsyncKeyState(int vKey)


GetAsyncKeyState determines whether a certain key is currently pressed and whether that key has been pressed since the last call to the function. This function fails if the thread calling it does not currently have the input focus.

Return Value

If the function fails (if the current thread does not have the input focus), the function returns 0. If the &H8000 bit of the return value is set, the key has been pressed at least once since the last time the thread called GetAsyncKeyState. If the &H1 bit of the return value is set, the key is currently pressed down.



Further Information:

For further information on Windows API functions such as these, and how to use these API's in your C# and VB.NET applications, please refer to the book 'Network programming in .NET' (Buy at Amazon UK) (Buy at Amazon US)

Visual Basic 6 example source code

Visual Basic .NET example source code

C# example source code

Provide a code example



Copyright 2018 Infinite Loop Ltd.