Hi,

Test in this way:

Code:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = vbKeyF1 Then
         'your code here
        MsgBox "Hallo!"
    End If
End Sub