One way would be:
VB Code:
  1. Private Sub Form_KeyPress(KeyAscii As Integer)
  2.     Timer1.Enabled = False: Timer1.Enabled = True
  3. End Sub
  4.  
  5. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  6.     Timer1.Enabled = False: Timer1.Enabled = True
  7. End Sub
  8.  
  9. Private Sub Timer1_Timer()
  10.     Unload Me
  11. End Sub
the form's KeyPreview property needs to be set to true.

That will only work well if you have a lot of the form exposed (i.e. not covered with controls so the MouseMove event doesn't fire).

Alternatively you could use GetCursorPos API on a timer to check the mouse position.