I have no idea why im even helping people here but just do this:
Code:
Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
For example if you want to close the program with the Escape key (a perfect timer interval would be around 15-25):
Code:
Private Sub ShutdownTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShutdownTimer.Tick
If GetKeyPress(Keys.Escape) Then
Me.Close()
End If
End Sub
Uncomplicated, no need of declaring new booleans and easy to use at all. The only problem i ever got with this was when it is part of a disabled timer. For example the timer is not ticking, you press the escape button and nothing happens of course. But right when you start the timer now it will close since for a split second the program thinks that the key is still pressed and runs the Me.Close part.