Click to See Complete Forum and Search --> : Esc key
netSurfer
Dec 7th, 1999, 09:25 PM
I need to capture when the user hits ESC. I don't know the ASCII Character Code for it and I'm not sure whether I can capture it like all the other keys or whether I need to use an API.
MR
Dec 7th, 1999, 09:47 PM
The keycode is vbKeyEscape and I believe its value is 27. You can capture this key.
In the keypress event it would look like if keyascii = vbkeyescape then whatever
For a command button you just need to set the cancel propery to true.
Hope this helps!
Pikachu_902
Dec 7th, 1999, 09:49 PM
the keycode for esc is 27
hayessj
Dec 7th, 1999, 09:49 PM
set the form's keypreview property to true
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
MsgBox "Escape"
End If
End Sub
netSurfer
Dec 7th, 1999, 09:59 PM
thanks, key code 27 is what I needed.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.