Determining the State of a Key on the Keyboard
.NET Framework 1.1 does not provide a managed way to determine if a key is pressed or not except for modifier keys (Control.ModifierKeys
). GetAsyncKeyState
can be used to determine if a key is pressed:
Imports System.Windows.Forms
⋮
Private Declare Auto Function GetAsyncKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Keys _
) As Boolean
Usage:
If GetAsyncKeyState(Keys.A) Then
⋮
End If