Hello guys.
I am facing an issue using some piece of code to create a hotkey
This is what I have which works fine (Checkbox is turnes on/off)

Module:

Code:
Public Declare Function GetAsyncKeyState Lib "USER32" _
    (ByVal vKey As Int32) _
    As Int16
Form Code:

Code:
Public Class Form1

Dim hotkey As Boolean

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

hotkey=true
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If hotkey = True Then
CheckBox1.Checked = True
hotkey = False
Else
CheckBox1.Checked = False
hotkey = True
End If

End Sub
End Class
Now, instead of a BUTTON, I use the following code to create a keyboard event

Code:
Private Sub KeyLogger_Tick() Handles KeyLogger.Tick
Dim hotkey As Boolean

hotkey = GetAsyncKeyState(Keys.NumPad1) 
If hotkey = True Then
CheckBox1.Checked = True
hotkey = False
Else
CheckBox1.Checked = False
hotkey = True
End If

End Sub
With this code, checkbox is turned on while NumPad1 is holding down. When I let it go, is turned off
How can I make checkbox turned on when NumPad1 is pressed once, and turned it off when NumPad1 is pressed once again?