Windows 3.1 Device Drivers (ddag31qh.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Virtual-Key Codes
◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
The virtual-key codes provide a hardware- and language-independent method of
identifying keyboard keys. Each virtual-key code represents a unique
keyboard key and also identifies the purpose of that key. The keyboard
driver must provide a translation table that maps keyboard scan codes to the
appropriate virtual-key codes.
Required Virtual Keys
The complete virtual-key code set consists of 256 byte values in the range 0
to 255. Most, but not all, of the values used by standard drivers are in the
range 0 to 127. There is a loose distinction between "standard" keys, which
do not vary much, and "OEM" keys, which do vary from keyboard to keyboard.
For full Windows functionality, a keyboard driver must provide the following
virtual keys:
Virtual-key code Description
────────────────────────────────────────────────────────────────────────────
VK_0 through VK_9 Number keys (not on numeric keypad): 0 through 9
VK_A through VK_Z Letter keys: A through Z
VK_BACK BACKSPACE key
VK_CONTROL CTRL key
VK_DELETE DELETE key
VK_DOWN Down direction key
VK_END END key
VK_ESCAPE ESC key
VK_F1 through VK_F10 F1 through F10 keys
VK_HOME HOME key
VK_INSERT INSERT key
VK_LEFT Left direction key
VK_MENU ALT key
VK_NEXT PAGE DOWN key
VK_PRIOR PAGE UP key
VK_RIGHT Right direction key
VK_SHIFT Left and right SHIFT keys
VK_SNAPSHOT PRINTSCREEN key
VK_SPACE SPACE key
VK_TAB TAB key
VK_UP Up direction key
Shift keys must be available in the combinations unshifted, SHIFT, CTRL, and
CTRL+ALT.
Most keyboards, the virtual-key codes VK_INSERT, VK_DELETE, VK_HOME, VK_END,
VK_PRIOR, and VK_NEXT are generated on the numeric keypad only if NUMLOCK is
off.
Optional Virtual Keys
If a keyboard has a numeric pad, the numeric keys are frequently used as
cursor-control and editing keys if NUMLOCK is off. If NUMLOCK is on, the
virtual-key codes VK_NUMPAD0 through VK_NUMPAD9 are used for the digits.
Keyboards with a DELETE key that also generates the decimal point (period or
comma) use VK_DELETE and VK_DECIMAL to distinguish between the two uses of
the key.
Keyboards commonly contain various "lock" keys, such as VK_CAPITAL and
VK_NUMLOCK. If a keyboard driver generates ANSI characters on the numeric
keypad using ALT + numeric-pad keys, it must do this translation only if
NUMLOCK is on. The cursor and editing keys on IBM-compatible keyboards do
not produce this translation.
Other keys may vary from keyboard to keyboard. The following set of
virtual-key codes is generally used for punctuation keys, accented letter
keys, and dead keys in the main section of a keyboard:
VK_OEM_1 .. VK_OEM_8
VK_OEM_102
VK_OEM_PLUS, VK_OEM_MINUS, VK_OEM_COMMA, VK_OEM_PERIOD
If a keyboard has more than 16 function keys, the virtual-key codes in the
range VK_F17 through VK_F24 should be used for the extra function keys.
Windows internally generates the mouse-button virtual-key codes VK_LBUTTON,
VK_RBUTTON, VK_MBUTTON, and VK_CANCEL. These virtual-key codes are generated
internally by Windows and are never generated by keyboard or mouse drivers.
Keyboard drivers should not generate VK_EXECUTE or VK_SEPARATER.
Virtual Keys for 122-Key Keyboards
For keyboards with 122 keys, the mapping for the first 101 keys is the same
as described in previous sections.
The function keys F13 through F24 should use VK_F13 through VK_F24.
The remaining keys should be mapped to the following virtual-key codes:
VK_ATTN VK_OEM_CLEAR
VK_CRSEL VK_PA1
VK_EREOF VK_PLAY
VK_EXSEL VK_ZOOM
VK_NONAME
Virtual-Key Code Definitions
The following table includes the virtual-key codes that are defined for
Windows. The key code values 0 and 0FFh are not used.
Name Value Comment
───────────────────────────────────────────────────────────────────────────
VK_LBUTTON 01h Left mouse button.
VK_RBUTTON 02h Right mouse button.
VK_CANCEL 03h Used for control-break processing.
VK_MBUTTON 04h Middle mouse button (3-button mouse).
05h through 07h undefined.
VK_BACK 08h
VK_TAB 09h
0Ah and 0Bh undefined.
VK_CLEAR 0Ch
VK_RETURN 0Dh
0Eh and 0Fh undefined.
VK_SHIFT 10h
VK_CONTROL 11h
VK_MENU 12h
VK_PAUSE 13h
VK_CAPITAL 14h
15h through 1Ah undefined.
VK_ESCAPE 1Bh
1Ch through 1Fh undefined.
VK_SPACE 20h
VK_PRIOR 21h Page up.
VK_NEXT 22h Page down.
VK_END 23h
VK_HOME 24h
VK_LEFT 25h
VK_UP 26h
VK_RIGHT 27h
VK_DOWN 28h
VK_SELECT 29h
VK_PRINT 2Ah Only used by Nokia.
VK_EXECUTE 2Bh Never used.
VK_SNAPSHOT 2Ch SYSREQ key starting with Windows 3.0.
VK_INSERT 2Dh
VK_DELETE 2Eh
VK_HELP 2Fh
VK_0 30h
VK_1 31h
VK_2 32h
VK_3 33h
VK_4 34h
VK_5 35h
VK_6 36h
VK_7 37h
VK_8 38h
VK_9 39h
3Ah though 40h undefined.
VK_A 41h
VK_B 42h
VK_C 43h
VK_D 44h
VK_E 45h
VK_F 46h
VK_G 47h
VK_H 48h
VK_I 49h
VK_J 4Ah
VK_K 4Bh
VK_L 4Ch
VK_M 4Dh
VK_N 4Eh
VK_O 4Fh
VK_P 50h
VK_Q 51h
VK_R 52h
VK_S 53h
VK_T 54h
VK_U 55h
VK_V 56h
VK_W 57h
VK_X 58h
VK_Y 59h
VK_Z 5Ah
5Bh through 5Fh undefined.
VK_NUMPAD0 60h
VK_NUMPAD1 61h
VK_NUMPAD2 62h
VK_NUMPAD3 63h
VK_NUMPAD4 64h
VK_NUMPAD5 65h
VK_NUMPAD6 66h
VK_NUMPAD7 67h
VK_NUMPAD8 68h
VK_NUMPAD9 69h
VK_MULTIPLY 6Ah
VK_ADD 6Bh
VK_SEPARATER 6Ch Never generated by keyboard driver.
VK_SUBTRACT 6Dh
VK_DECIMAL 6Eh
VK_DIVIDE 6Fh
VK_F1 70h
VK_F2 71h
VK_F3 72h
VK_F4 73h
VK_F5 74h
VK_F6 75h
VK_F7 76h
VK_F8 77h
VK_F9 78h
VK_F10 79h
VK_F11 7Ah
VK_F12 7Bh
VK_F13 7Ch
VK_F14 7Dh
VK_F15 7Eh
VK_F16 7Fh
VK_F17 80h
VK_F18 81h
VK_F19 82h
VK_F20 83h
VK_F21 84h
VK_F22 85h
VK_F23 86h
VK_F24 87h
88h through 8Fh unassigned.
VK_NUMLOCK 090h NUMLOCK on all keyboards.
VK_OEM_SCROLL 091h SCROLL LOCK on all keyboards.
92h through B9h unassigned.
VK_OEM_1 0BAh Punctuation.
VK_OEM_PLUS 0BBh Punctuation.
VK_OEM_COMMA 0BCh Punctuation.
VK_OEM_MINUS 0BDh Punctuation.
VK_OEM_PERIOD 0BEh Punctuation.
VK_OEM_2 0BFh Punctuation.
VK_OEM_3 0C0h Punctuation.
C1h through DAh unassigned.
VK_OEM_4 0DBh Punctuation.
VK_OEM_5 0DCh Punctuation.
VK_OEM_6 0DDh Punctuation.
VK_OEM_7 0DEh Punctuation.
VK_OEM_8 0DFh Punctuation.
VK_F17 0E0h F17 key on Olivetti extended keyboard (internal use
only).
VK_F18 0E1h F18 key on Olivetti extended keyboard (internal use
only).
VK_OEM_102 0E2h < or | on IBM-compatible 102 enhanced keyboard
(non-U.S.).
VK_ICO_HELP 0E3h Help key on Olivetti extended keyboard (internal use
only).
VK_ICO_00 0E4h 00 key on Olivetti extended keyboard (internal use
only).
E5h unassigned.
VK_ICO_CLEAR 0E6h Olivetti extended keyboard (internal use only).
E7h and E8h unassigned.
VK_OEM_RESET 0E9H Only used by Nokia.
VK_OEM_JUMP 0EAH Only used by Nokia.
VK_OEM_PA1 0EBH Only used by Nokia.
VK_OEM_PA2 0ECH Only used by Nokia.
VK_OEM_PA3 0EDH Only used by Nokia.
VK_OEM_WSCTRL 0EEH Only used by Nokia.
VK_OEM_CUSEL 0EFH Only used by Nokia.
VK_OEM_ATTN 0F0H Only used by Nokia.
VK_OEM_FINNISH 0F1H Only used by Nokia.
VK_OEM_COPY 0F2H Only used by Nokia.
VK_OEM_AUTO 0F3H Only used by Nokia.
VK_OEM_ENLW 0F4h Only used by Nokia.
VK_OEM_BACKTAB 0F5h Only used by Nokia.
VK_ATTN 0F6H
VK_CRSEL 0F7H
VK_EXSEL 0F8H
VK_EREOF 0F9H
VK_PLAY 0FAH
VK_ZOOM 0FBH
VK_NONAME 0FCH
VK_PA1 0FDH
VK_OEM_CLEAR 0FEH
♦