ascii keycode

12-20-2001, 02:18 PM
Can anyone tell me the code for stuff like ctrl and alt, or maybe some place that I can find it.


12-20-2001, 02:23 PM
<pre>Key Codes

Constant Value Description
vbKeyLButton 1 Left mouse button
vbKeyRButton 2 Right mouse button
vbKeyCancel 3 CANCEL key
vbKeyMButton 4 Middle mouse button
vbKeyBack 8 BACKSPACE key
vbKeyTab 9 TAB key
vbKeyClear 12 CLEAR key
vbKeyReturn 13 ENTER key
vbKeyShift 16 SHIFT key
vbKeyControl 17 CTRL key
vbKeyMenu 18 MENU key
vbKeyPause 19 PAUSE key
vbKeyCapital 20 CAPS LOCK key
vbKeyEscape 27 ESC key
vbKeySpace 32 SPACEBAR key
vbKeyPageUp 33 PAGE UP key
vbKeyPageDown 34 PAGE DOWN key
vbKeyEnd 35 END key
vbKeyHome 36 HOME key
vbKeyLeft 37 LEFT ARROW key
vbKeyUp 38 UP ARROW key
vbKeyRight 39 RIGHT ARROW key
vbKeyDown 40 DOWN ARROW key
vbKeySelect 41 SELECT key
vbKeyPrint 42 PRINT SCREEN key
vbKeyExecute 43 EXECUTE key
vbKeySnapshot 44 SNAPSHOT key
vbKeyInsert 45 INS key
vbKeyDelete 46 DEL key
vbKeyHelp 47 HELP key
vbKeyNumlock 144 NUM LOCK key</pre>

12-20-2001, 02:23 PM
Well, the KeyPress event doesn't trap Alt, Shift or Control, but here's a way to do it:
<pre><font color=blue>Private Sub</font color=blue> Form_KeyDown(KeyCode <font color=blue>As Integer</font color=blue>, Shift <font color=blue>As Integer</font color=blue>)
<font color=blue>Select Case</font color=blue> Shift
<font color=blue>Case</font color=blue> vbCtrlMask
MsgBox "Control was pressed!"
<font color=blue>Case</font color=blue> vbShiftMask
MsgBox "Shift was pressed!"
<font color=blue>Case</font color=blue> vbAltMask
MsgBox "Alt was pressed!"
<font color=blue>End Select</font color=blue>
<font color=blue>End Sub</font color=blue>

12-21-2001, 12:51 PM
Thanks for the code and the sub routine.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum