Compartilhar via


Keys and Key Codes for Windows Mobile

4/8/2010

Windows Mobile maintains a device–independent keyboard model that enables it to support a variety of keyboards. At the lowest level, each key on the keyboard generates a scan code when the key is pressed and released. The scan code is a hardware–dependent number that identifies the key. The keyboard driver translates or maps each scan code to a virtual key code. The virtual key code is a hardware–independent hexadecimal number that identifies the key. Because keyboard layouts vary from language to language, Windows Mobile offers only the core set of virtual key codes that are found on all keyboards. This core set includes English characters, numbers, and a few critical keys, such as the function and arrow keys. Keys that are not included in the core set also have virtual key code assignments, but their values vary from one keyboard layout to the next. You should depend only on the virtual key codes that are in the core set.

Key Codes

The following table shows the symbolic constant names, hexadecimal values, and keyboard equivalents for the virtual key codes used by the Windows Mobile operating system. The codes are listed in numeric order. You can combine any of the codes with a modifier key to create a hot key.

A VK_code is a byte, and so there are only 256 VK_codes total. The virtual key codes listed in the "Virtual key codes" section below are shared with Windows Embedded CE. More virtual keys were required for functionality, and so many hex values are shared between both a traditional Windows Embedded CE value and a Windows Mobile–specific value.

The following table provides a list of the mappings between the traditional VK constants and the additional Windows Mobile–specific value.

Hexadecimal value Windows Embedded CE constant Shared Windows Mobile constant Windows Mobile purpose

0x08

VK_BACK

VK_TBACK

Back.

0x0D

VK_RETURN

VK_TACTION

Action.

0x25

VK_LEFT

VK_TLEFT 

Left.

0x26

VK_UP

VK_TUP

Up.

0x27

VK_RIGHT

VK_TRIGHT

Right.

0x28

VK_DOWN

VK_TDOWN

Down.

0x5B

VK_LWIN

VK_THOME

Home screen

0x70

VK_F1

VK_TSOFT1

Softkey 1.

0x71

VK_F2

VK_TSOFT2

Softkey 2.

0x72

VK_F3

VK_TTALK

Talk

0x73

VK_F4

VK_TEND

End

0x75

VK_F6

VK_TVOLUMEUP

Volume Up.

0x76

VK_F7

VK_TVOLUMEDOWN

Volume Down.

0x77

VK_F8

VK_TSTAR

*

0x78

VK_F9

VK_TPOUND

#

0x79

VK_F10

VK_TRECORD

Record.

0x7A

VK_F11

VK_SYMBOL

Symbol (SYM) key.

0x7E

VK_F15

VK_END_ALL_DATA_CALLS

Disconnects all data calls without affecting the status of voice calls.

0x7F

VK_F16

VK_TSPEAKERPHONE_TOGGLE

Toggles speakerphone on and off.

0x80

VK_F17

VK_TFLIP

Flip.

0x81

VK_F18

VK_TPOWER

Power.

0x82

VK_F19

VK_REDKEY

Sent by a keypad that has a special red function key.

0x83

VK_F20

VK_ROCKER

Arrow keys came from a Rocker.

0x84

VK_F21

VK_DPAD

Arrow keys came from a d–pad.

0x85

VK_F22

VK_KEYLOCK

Key used to lock device.

0x86

VK_F23

VK_ACTION

Sent with VK_RETURN when doing Action on Windows Mobile Classic rockers.

0x87

VK_F24

VK_VOICEDIAL

Key used to kick off voice dial recognition.

For more information about the d-pad, see D-pad Virtual Key Code Support. For more information about soft keys, see Soft Key Virtual Key Codes.

Note

Beginning with Windows Mobile 6.5.3, soft keys are replaced by touchable tiles on Windows Mobile Professional phones.

The following keys were undefined for Windows Embedded CE, but are overridden as application keys in Windows Mobile.

Hexadecimal value Windows Mobile constant

0xC1

VK_APP_FIRST

0xC1

VK_APP1

0xC2

VK_APP2

0xC3

VK_APP3

0xC4

VK_APP4

0xC5

VK_APP5

0xC6

VK_APP6

0xC6

VK_APP_LAST

The VK_APP keys will only be recognized by the system if they are wrapped with VK_LWIN. The following code snippet demonstrates how to do this programmatically.

keybd_event(VK_LWIN, 0, KEYEVENTF_SILENT, 0);
GenKeyEvent(VK_APP1);
keybd_event(VK_LWIN, 0, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0);

And finally, the following chorded keys are implemented for Windows Mobile.

Windows Mobile constant Hexadecimal value Purpose

VK_DONE

VK_RWIN + VK_F6

<OK/Close> hotkey code.

See SmartMinimize Button.

MOD_DONE

(MOD_WIN | MOD_KEYUP)

<OK/Close> hotkey modifiers

VK_MOJI

VK_RWIN + VK_F7

Key used to switch between East Asian language layouts.

MOD_MOJI

(MOD_WIN | MOD_KEYUP)

Modifiers so MOJI goes to the shell.

VK_A to VK_Z and VK_0 to VK_9 are defined to be the same values as their ASCII counterparts. So VK_A is 0x41 and VK_0 is 0x30. Windows Mobile also defines the following numerical codes.

Hexadecimal value Windows Embedded CE constant Windows Mobile constant

0x30

VK_0

VK_T0

0x31

VK_1

VK_T1

0x32

VK_2

VK_T2

0x33

VK_3

VK_T3

0x34

VK_4

VK_T4

0x35

VK_5

VK_T5

0x36

VK_6

VK_T6

0x37

VK_7

VK_T7

0x38

VK_8

VK_T8

0x39

VK_9

VK_T9

VK_0 (which is the same as VK_T0) and VK_NUMPAD0 are different keys. On the desktop keyboard, VK_0 is the key just above and to the left of VK_P. VK_NUMPAD0 is the key at the bottom of the number pad on the far right of the keyboard. Windows Mobile applications will always look for VK_0, but can also look for both VK_0 and VK_NUMPAD0 in order to do the correct thing if there was a device with a numpad.

Virtual key codes in Windows Mobile

Symbolic constant Hexadecimal value Additional mapping defined for Windows Mobile Mouse or keyboard equivalent

VK_LBUTTON

0x01

 

Left mouse button.

VK_RBUTTON

0x02

 

Right mouse button.

VK_CANCEL

0x03

 

Control–break processing.

VK_MBUTTON

0x04

 

Middle mouse button on a three–button mouse.

 

0x05–0x07

 

Undefined.

VK_BACK

0x08

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

BACKSPACE key.

VK_TAB

0x09

 

TAB key.

 

0x0A–0x0B

 

Undefined.

VK_CLEAR

0x0C

 

CLEAR key.

VK_RETURN

0x0D

 

ENTER key.

 

0x0E–0x0F

 

Undefined.

VK_SHIFT

0x10

 

SHIFT key.

VK_CONTROL

0x11

 

CTRL key.

VK_MENU

0x12

 

ALT key.

VK_PAUSE

0x13

 

PAUSE key.

VK_CAPITAL

0x14

 

CAPS LOCK key.

 

0x15–0x19

 

Reserved for Kanji systems.

 

0x1A

 

Undefined.

VK_ESCAPE

0x1B

 

ESC key.

 

0x1C–0x1F

 

Reserved for Kanji systems.

VK_SPACE

0x20

 

SPACEBAR.

VK_PRIOR

0x21

 

PAGE UP key.

VK_NEXT

0x22

 

PAGE DOWN key.

VK_END

0x23

 

END key.

VK_HOME

0x24

 

HOME key.

VK_LEFT

0x25

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

LEFT ARROW key.

VK_UP

0x26

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

UP ARROW key.

VK_RIGHT

0x27

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

RIGHT ARROW key.

VK_DOWN

0x28

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

DOWN ARROW key.

VK_SELECT

0x29

 

SELECT key.

 

0x2A

 

Specific to OEM.

VK_EXECUTE

0x2B

 

EXECUTE key.

VK_SNAPSHOT

0x2C

 

PRINT SCREEN key.

VK_INSERT

0x2D

 

INS key.

VK_DELETE

0x2E

 

DEL key.

VK_HELP

0x2F

 

HELP key.

 

0x3A–0x40

 

Undefined.

VK_LWIN

0x5B

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

Left Windows key on a Microsoft Natural Keyboard.

VK_RWIN

0x5C

 

Right Windows key on a Microsoft Natural Keyboard.

VK_APPS

0x5D

 

Applications key on a Microsoft Natural Keyboard.

 

0x5E–0x5F

 

Undefined

VK_NUMPAD0

0x60

 

Numeric keypad 0 key.

VK_NUMPAD1

0x61

 

Numeric keypad 1 key.

VK_NUMPAD2

0x62

 

Numeric keypad 2 key.

VK_NUMPAD3

0x63

 

Numeric keypad 3 key.

VK_NUMPAD4

0x64

 

Numeric keypad 4 key.

VK_NUMPAD5

0x65

 

Numeric keypad 5 key.

VK_NUMPAD6

0x66

 

Numeric keypad 6 key.

VK_NUMPAD7

0x67

 

Numeric keypad 7 key.

VK_NUMPAD8

0x68

 

Numeric keypad 8 key.

VK_NUMPAD9

0x69

 

Numeric keypad 9 key.

VK_MULTIPLY

0x6A

 

Multiply key.

VK_ADD

0x6B

 

Add key.

VK_SEPARATOR

0x6C

 

Separator key.

VK_SUBTRACT

0x6D

 

Subtract key.

VK_DECIMAL

0x6E

 

Decimal key.

VK_DIVIDE

0x6F

 

Divide key.

VK_F1

0x70

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F1 key.

VK_F2

0x71

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F2 key.

VK_F3

0x72

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F3 key.

VK_F4

0x73

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F4 key.

VK_F5

0x74

 

F5 key.

VK_F6

0x75

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F6 key.

VK_F7

0x76

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F7 key.

VK_F8

0x77

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F8 key.

VK_F9

0x78

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F9 key.

VK_F10

0x79

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F10 key.

VK_F11

0x7A

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F11 key.

VK_F12

0x7B

 

F12 key.

VK_F13

0x7C

 

F13 key.

VK_F14

0x7D

 

F14 key.

VK_F15

0x7E

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F15 key.

VK_F16

0x7F

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F16 key.

VK_F17

0x80

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F17 key.

VK_F18

0x81

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F18 key.

VK_F19

0x82

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F19 key.

VK_F20

0x83

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F20 key.

VK_F21

0x84

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F21 key.

VK_F22

0x85

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F22 key.

Key used to lock device.

VK_F23

0x86

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F23 key.

VK_F24

0x87

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

F24 key.

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

 

0x89–0x8F

 

Unassigned.

VK_NUMLOCK

0x90

 

NUM LOCK key.

VK_SCROLL

0x91

 

SCROLL LOCK key.

VK_LSHIFT

0xA0

 

Left SHIFT.

VK_RSHIFT

0xA1

 

Right SHIFT.

VK_LCONTROL

0xA2

 

Left CTRL.

VK_RCONTROL

0xA3

 

Right CTRL.

VK_LMENU

0xA4

 

Left ALT.

VK_RMENU

0xA5

 

Right ALT.

 

0xBA–0xC0

 

Specific to OEM; reserved. See following tables.

 

0xC1–0xDA

Bb431750.132a2c76-9b1b-4d0c-b93c-eedf0c76fcf4(en-us,MSDN.10).gif

0xC1–0xC6

Unassigned.

 

0xDB–0xDE

 

Specific to OEM; reserved. See following tables.

VK_OFF

0xDF

 

Used to power the device on and off. No keyboard equivalent.

 

0xE1–0xE4

 

Specific to OEM.

 

0xE5

 

Unassigned.

 

0xE6

 

Specific to OEM.

VK_PACKET

0xE7

 

Used to pass Unicode characters as if they were keystrokes. If VK_PACKET is used with SendInput, then the Unicode character to be delivered should be placed into the lower 16 bits of the scan code. If a keyboard message is removed from the message queue and the virtual key is VK_PACKET, then the Unicode character will be the upper 16 bits of the lparam.

 

0xE8

 

Unassigned.

 

0xE9–0xF5

 

Specific to OEM.

VK_ATTN

0xF6

 

ATTN key.

VK_CRSEL

0xF7

 

CRSEL key.

VK_EXSEL

0xF8

 

EXSEL key.

VK_EREOF

0xF9

 

Erase EOF key.

VK_PLAY

0xFA

 

PLAY key.

VK_ZOOM

0xFB

 

ZOOM key.

VK_NONAME

0xFC

 

Reserved for future use.

VK_PA1

0xFD

 

PA1 key.

VK_OEM_CLEAR

0xFE

 

CLEAR key.

VK_KEYLOCK

0xF22

 

Key used to lock device.

OEMs should make special note of the VK key ranges reserved for specific OEM use: 2A, DB–E4, E6, and E9–F5.

In addition to the virtual key assignments in the previous table, Microsoft has assigned the following specific OEM virtual keys.

Symbolic constant Hexadecimal value Mouse or keyboard equivalent

VK_OEM_SCROLL

0x91

None.

VK_OEM_1

0xBA

";:" for US.

VK_OEM_PLUS

0xBB

"+" any country/region.

VK_OEM_COMMA

0xBC

"," any country/region.

VK_OEM_MINUS

0xBD

"-" any country/region.

VK_OEM_PERIOD

0xBE

"." any country/region.

VK_OEM_2

0xBF

"/?" for US.

VK_OEM_3

0xC0

"`~" for US.

VK_OEM_4

0xDB

"[{" for US.

VK_OEM_5

0xDC

"\|" for US.

VK_OEM_6

0xDD

"]}" for US

VK_OEM_7

0xDE

"'"" for US.

VK_OEM_8

0xDF

None. By default, this is equivalent to VK_OFF.

VK_OEM_AX

0xE1

AX key on Japanese AX keyboard.

VK_OEM_102

0xE2

"<>" or "\|" on RT 102-key keyboard.

For East Asian Input Method Editors (IMEs) the following additional virtual keyboard definitions must be observed.

Symbolic constant Hexadecimal value Description

VK_DBE_ALPHANUMERIC

0x0f0

Changes the mode to alphanumeric.

VK_DBE_KATAKANA

0x0f1

Changes the mode to Katakana.

VK_DBE_HIRAGANA

0x0f2

Changes the mode to Hiragana.

VK_DBE_SBCSCHAR

0x0f3

Changes the mode to single–byte characters.

VK_DBE_DBCSCHAR

0x0f4

Changes the mode to double–byte characters.

VK_DBE_ROMAN

0x0f5

Changes the mode to Roman characters.

VK_DBE_NOROMAN

0x0f6

Changes the mode to non–Roman characters.

VK_DBE_ENTERWORDREGISTERMODE

0x0f7

Activates the word registration dialog box.

VK_DBE_ENTERIMECONFIGMODE

0x0f8

Activates a dialog box for setting up an IME environment.

VK_DBE_FLUSHSTRING

0x0f9

Deletes the undetermined string without determining it.

VK_DBE_CODEINPUT

0x0fa

Changes the mode to code input.

VK_DBE_NOCODEINPUT

0x0fb

Changes the mode to no-code input.

OEMs should not use the unassigned portions of the virtual key (VK) mapping tables. Microsoft will assign these values in the future. If manufacturers require additional VK mappings, they should reuse some of the current manufacturer–specific and vendor–specific assignments.

See Also

Reference

WM_CHAR

Concepts

Processing Character Messages

Other Resources

Keyboard
Navigation Keys
Message Map for Navigation Controls