When F5 is pressed, i need to run a function, is there a stable way to do this? i remember before i found scripts run in timers with 1ms which didnt work too well.
Printable View
When F5 is pressed, i need to run a function, is there a stable way to do this? i remember before i found scripts run in timers with 1ms which didnt work too well.
Hey joey have tried getasyncstate, but for that you have to use timer :-
set the time inerval to minimum....Code:Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer
If GetAsyncKeyState(vbKeyF8) <> 0 Then
' Do something
End If
End Sub
hhope it'll work
I id this in the KeyDown event but it can also be put in the KeyUp event if you wish.
Code:Option Explicit
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 116 Then
MsgBox "F5 was pressed. Call your function here"
End If
End Sub