Results 1 to 3 of 3

Thread: Trap function keys

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2001
    Location
    Boise, ID
    Posts
    25

    Angry Trap function keys

    How do you trap the function keys (such as:F1, F2,....) on the keypress event? Or know when that key is pressed?

    Or is there an ascii code for these function keys?
    Plz reply, it's urgent
    thanks.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You don't use the KeyPress event for Function keys. Use either the KeyUp or KeyDown event. Example:
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.         If KeyCode = vbKeyF1 Then
    3.            MsgBox "You hit F1"
    4.         End If
    5. End Sub
    Make sure the Form's KeyPreview property is set to True (by default, it is False)

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Yes, you are correct, the function keys are vbKeyF1 through vbKeyF12.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width