Get System Wide KeyUp event

false74

Well-known member
Joined
Aug 4, 2010
Messages
76
Programming Experience
Beginner
Currently I am able to see if a key is currently pressed via the GetAsyncKeyState function. Currently I just simply have a timer running in the background that constantly checks if a certain key is pressed in order to run a command. However my issue is if the user holds down the key it will continually run that bit of code over and over per timer tick. Is there a way or another function to detect a keyup or keypress only. This is my current code to detect keys:

VB.NET:
Expand Collapse Copy
        Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Windows.Forms.Keys) As Integer
        Public ReadOnly Property CurrKey(ByVal key As Windows.Forms.Keys) As Boolean
            Get
                Return CBool(GetAsyncKeyState(key))
            End Get
        End Property
 
Last edited:
Back
Top