Sometimes you need to determine whether a particular key is pressed or noteven though the application is not active. "GetAsyncKeyState" comes to the rescue. This function takes a virtual key code as a parameter and returns non-zero if the function succeeds.
Here's a sample app for capturing the 'F5' key. In this example, I call GetAsyncKeyState in a timer, so that it can capture the key press event.
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_F5 = &H74
Private Sub Timer1_Timer()
If GetAsyncKeyState(VK_F5) <> 0 Then
Text1.Text = "F5 Pressed..."