Where can I find different keyascii values for the F keys?
Or how can I do this:
Either using ascii or another replacement for an F key?
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = bah Then
03-27-2004, 10:46 PM
By "F Keys" do you mean the Function keys? If so you cannot detect those in the KeyPress event. You can use the following code to demonstrate this to yourself:
Private Sub Text1_KeyPress(KeyAscii As Integer)
You CAN capture the Function keys, navigation keys, etc. using the KeyDown and KeyUp events.
VB comes with a set of predefined constants for the function keys - vbKeyF1 can be used to detect this key:
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then
MsgBox "The F1 key was pressed"
EDIT: I forgot to add - you can get the various keycode constants from the Object Browser in the VB IDE. Right-mouse in the code window and select KeyCode Constants in the Class pane.