Skip to content

KeyCodeConstants

Virtual-key codes reported in the KeyCode argument of KeyDown and KeyUp events. The values match the underlying Windows virtual-key codes (VK_*).

INFO

In classic VBA, KeyCodeConstants is a module of standalone constants; in VB6 and twinBASIC it is an enumeration.

Mouse buttons and modifiers

ConstantValueDescription
vbKeyLButton1Left mouse button.
vbKeyRButton2Right mouse button.
vbKeyMButton4Middle mouse button.
vbKeyShift16Shift.
vbKeyControl17Ctrl.
vbKeyMenu18Alt.

Editing and navigation

ConstantValueDescription
vbKeyCancel3Ctrl+Break.
vbKeyBack8Backspace.
vbKeyTab9Tab.
vbKeyClear12Clear (numeric pad 5 without Num Lock).
vbKeyReturn13Enter.
vbKeyPause19Pause.
vbKeyCapital20Caps Lock.
vbKeyEscape27Esc.
vbKeySpace32Space.
vbKeyPageUp33Page Up.
vbKeyPageDown34Page Down.
vbKeyEnd35End.
vbKeyHome36Home.
vbKeyLeft37Left arrow.
vbKeyUp38Up arrow.
vbKeyRight39Right arrow.
vbKeyDown40Down arrow.
vbKeySelect41Select.
vbKeyPrint42Print.
vbKeyExecute43Execute.
vbKeySnapshot44Print Screen.
vbKeyInsert45Insert.
vbKeyDelete46Delete.
vbKeyHelp47Help.
vbKeyNumlock144Num Lock.
vbKeyScrollLock145Scroll Lock.

Letter keys

ConstantValueDescription
vbKeyA -- vbKeyZ65 -- 90The letters A through Z.

Number keys

ConstantValueDescription
vbKey0 -- vbKey948 -- 57The digits 0 through 9 on the main keyboard.

Numeric keypad

ConstantValueDescription
vbKeyNumpad0 -- vbKeyNumpad996 -- 105The digits 0 through 9 on the numeric keypad.
vbKeyMultiply106* on the numeric keypad.
vbKeyAdd107+ on the numeric keypad.
vbKeySeparator108Numeric-keypad separator.
vbKeySubtract109- on the numeric keypad.
vbKeyDecimal110. on the numeric keypad.
vbKeyDivide111/ on the numeric keypad.

Function keys

ConstantValueDescription
vbKeyF1 -- vbKeyF16112 -- 127The function keys F1 through F16.

twinBASIC and LOGO copyright of "WaynePhillipsEA" author