Virtual Key Codes

From RAD Studio
Jump to: navigation, search

Go Up to API Categories Index

Virtual Key codes provide a symbolic representation of user key presses.

Virtual key codes allow you to represent keyboard values for non-alphanumeric keys. Windows defines special constants for each key the user can press. These constants can then be used to refer to the keystroke in Windows API calls or in an OnKeyUp or OnKeyDown event handler. Most of the virtual key codes are defined in the Windows unit.

The following table lists the virtual key codes defined in the Windows unit:

Virtual Key Code Corresponding Key

VK_LBUTTON

Left mouse button

VK_RBUTTON

Right mouse button

VK_CANCEL

Control+Break

VK_MBUTTON

Middle mouse button

VK_XBUTTON1

Left lateral mouse button

VK_XBUTTON2

Right lateral mouse button

VK_BACK

Backspace key

VK_TAB

Tab key

VK_CLEAR

Clear key

VK_RETURN

Enter key

VK_SHIFT

Shift key

VK_CONTROL

Ctrl key

VK_MENU

Alt key

VK_PAUSE

Pause key

VK_CAPITAL

Caps Lock key

VK_KANA

Used with IME

VK_HAGUL

Used with IME

VK_JUNJA

Used with IME

VK_FINAL

Used with IME

VK_HANJA

Used with IME

VK_KANJI

Used with IME

VK_CONVERT

Used with IME

VK_NONCONVERT

Used with IME

VK_ACCEPT

Used with IME

VK_MODECHANGE

Used with IME

VK_ESCAPE

Esc key

VK_SPACE

Space key

VK_PRIOR

Page Up key

VK_NEXT

Page Down key

VK_END

End key

VK_HOME

Home key

VK_LEFT

Left Arrow key

VK_UP

Up Arrow key

VK_RIGHT

Right Arrow key

VK_DOWN

Down Arrow key

VK_SELECT

Select key

VK_PRINT

Print key (keyboard-specific)

VK_EXECUTE

Execute key

VK_SNAPSHOT

Print Screen key

VK_INSERT

Insert key

VK_DELETE

Delete key

VK_HELP

Help key

VK_LWIN

Left Windows key (Microsoft keyboard)

VK_RWIN

Right Windows key (Microsoft keyboard)

VK_APPS

Applications key (Microsoft keyboard)

VK_NUMPAD0

0 key (numeric keypad)

VK_NUMPAD1

1 key (numeric keypad)

VK_NUMPAD2

2 key (numeric keypad)

VK_NUMPAD3

3 key (numeric keypad)

VK_NUMPAD4

4 key (numeric keypad)

VK_NUMPAD5

5 key (numeric keypad)

VK_NUMPAD6

6 key (numeric keypad)

VK_NUMPAD7

7 key (numeric keypad)

VK_NUMPAD8

8 key (numeric keypad)

VK_NUMPAD9

9 key (numeric keypad)

VK_MULTIPLY

Multiply key (numeric keypad)

VK_ADD

Add key (numeric keypad)

VK_SEPARATOR

Separator key (numeric keypad)

VK_SUBTRACT

Subtract key (numeric keypad)

VK_DECIMAL

Decimal key (numeric keypad)

VK_DIVIDE

Divide key (numeric keypad)

VK_F1

F1 key

VK_F2

F2 key

VK_F3

F3 key

VK_F4

F4 key

VK_F5

F5 key

VK_F6

F6 key

VK_F7

F7 key

VK_F8

F8 key

VK_F9

F9 key

VK_F10

F10 key

VK_F11

F11 key

VK_F12

F12 key

VK_F13

F13 key

VK_F14

F14 key

VK_F15

F15 key

VK_F16

F16 key

VK_F17

F17 key

VK_F18

F18 key

VK_F19

F19 key

VK_F20

F20 key

VK_F21

F21 key

VK_F22

F22 key

VK_F23

F23 key

VK_F24

F24 key

VK_NUMLOCK

Num Lock key

VK_SCROLL

Scroll Lock key

VK_LSHIFT

Left Shift key (only used with GetAsyncKeyState and GetKeyState)

VK_RSHIFT

Right Shift key (only used with GetAsyncKeyState and GetKeyState)

VK_LCONTROL

Left Ctrl key (only used with GetAsyncKeyState and GetKeyState)

VK_RCONTROL

Right Ctrl key (only used with GetAsyncKeyState and GetKeyState)

VK_LMENU

Left Alt key (only used with GetAsyncKeyState and GetKeyState)

VK_RMENU

Right Alt key (only used with GetAsyncKeyState and GetKeyState)

VK_BROWSER_BACK

Browser Back key (Windows 2000/XP)

VK_BROWSER_FORWARD

Browser Forward key (Windows 2000/XP)

VK_BROWSER_REFRESH

Browser Refresh key (Windows 2000/XP)

VK_BROWSER_STOP

Browser Stop key (Windows 2000/XP)

VK_BROWSER_SEARCH

Browser Search key (Windows 2000/XP)

VK_BROWSER_FAVORITES

Browser Favorites key (Windows 2000/XP)

VK_BROWSER_HOME

Browser Start and Home key (Windows 2000/XP)

VK_VOLUME_MUTE

Volume Mute key (Windows 2000/XP)

VK_VOLUME_DOWN

Volume Down key (Windows 2000/XP)

VK_VOLUME_UP

Volume Up key (Windows 2000/XP)

VK_MEDIA_NEXT_TRACK

Next Track key (Windows 2000/XP)

VK_MEDIA_PREV_TRACK

Previous Track key (Windows 2000/XP)

VK_MEDIA_STOP

Stop Media key (Windows 2000/XP)

VK_MEDIA_PLAY_PAUSE

Play/Pause Media key (Windows 2000/XP)

VK_LAUNCH_MAIL

Start Mail key (Windows 2000/XP)

VK_LAUNCH_MEDIA_SELECT

Select Media key (Windows 2000/XP)

VK_LAUNCH_APP1

Start Application1 key (Windows 2000/XP)

VK_LAUNCH_APP2

Start Application2 key (Windows 2000/XP)

VK_OEM_1

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key (Windows 2000/XP)

VK_OEM_PLUS

For any country/region, the '+' key (Windows 2000/XP)

VK_OEM_COMMA

For any country/region, the ',' key (Windows 2000/XP)

VK_OEM_MINUS

For any country/region, the '-' key (Windows 2000/XP)

VK_OEM_PERIOD

For any country/region, the '.' key (Windows 2000/XP)

VK_OEM_2

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key (Windows 2000/XP)

VK_OEM_3

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key (Windows 2000/XP)

VK_OEM_4

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key (Windows 2000/XP)

VK_OEM_5

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key (Windows 2000/XP)

VK_OEM_6

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key (Windows 2000/XP)

VK_OEM_7

Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ''"' key (Windows 2000/XP)

VK_OEM_8

Used for miscellaneous characters; it can vary by keyboard. (Windows 2000/XP)

VK_OEM_102

Either the angle bracket key or the backslash key on the RT 102-key keyboard (Windows 2000/XP)

VK_PACKET

Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. (Windows 2000/XP)

VK_PROCESSKEY

IME PROCESS key (Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP)

VK_ATTN

Attn key

VK_CRSEL

CrSel key

VK_EXSEL

ExSel key

VK_EREOF

Erase EOF key

VK_PLAY

Play key

VK_ZOOM

Zoom key

VK_NONAME

Reserved for future use

VK_PA1

PA1 key

VK_OEM_CLEAR

Clear key



See Also