List of virtual keys in Windows messages (VC virtual key)
Vk_lbutton left mouse button 0x01 Vk_rbutton right mouse button 0x02 Vk_cancel Ctrl + Break 0x03 Vk_mbutton Mouse middle button 0x04 Vk_back Backspace Key 0x08 Vk_tab TAB Key 0x09 Vk_return Enter 0x0D Vk_shift SHIFT Key 0x10 Vk_control Ctrl Key 0x11 Vk_menu Alt Key 0x12 Vk_pause PAUSE Key 0x13 Vk_capital Caps Lock Key 0x14 Vk_escape ESC Key 0x1b Vk_space Space bar 0x20 Vk_prior Page up key 0x21 Vk_next Page down key 0x22 Vk_end End Key 0x23 Vk_home Home Key 0x24 Vk_left left ARROW key 0x25 Vk_up Up ARROW keys 0x26 Vk_right RIGHT ARROW key 0x27 Vk_down down ARROW key 0x28 Vk_snapshot Print Screen Key 0x2c Vk_insert INSERT Key 0x2d Vk_delete DELETE Key 0x2e ' 0 ' – ' 9 ' digital 0-9 0x30-0x39 ' A ' – ' Z ' letter-A-Z 0x41-0x5a Vk_lwin left Winkey (104 keyboard only) 0x5b Vk_rwin Right Winkey (104 keyboard only) 0x5c Vk_apps Appskey (104 keyboards only) 0x5d vk_numpad0 keypad 0 Keys 0x60 VK_NUMPAD1 keypad 1 Keys 0x61 VK_NUMPAD2 keypad 2 Keys 0x62 VK_NUMPAD3 Keypad 3 Keys 0x63 VK_NUMPAD4 Keypad 4 Keys 0x64 VK_NUMPAD5 keypad 5 Keys 0x65 VK_NUMPAD6 keypad 6 Keys 0x66 VK_NUMPAD7 keypad 7 Keys 0x67 Vk_numpad8 keypad 8 Keys 0x68 VK_NUMPAD9 keypad 9 Keys 0x69 Vk_f1-vk_f24 function Key F1–f24 0x70-0x87 Vk_numlock num Lock Key 0x90 Vk_scroll SCROLL Lock Key 0x91 |
The mouse or keyboard key specified by the symbol constant hexadecimal value
Vk_lbutton 01 left mouse button
Vk_rbutton 02 right mouse button
Vk_cancel Control-break Process
Vk_mbutton 04 Middle mouse button
Vk_back-BACKSPACE
Vk_tab Tab key
Vk_clear 0C Clear Key
Vk_return 0D Enter key
Vk_shift SHIFT Key
Vk_control CTRL key
Vk_menu ALT Key
Vk_pause PAUSE Key
Vk_capital CAPS LOCK Key
Vk_escape 1 B ESC key
Vk_space SPACEBAR
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 Arrow Arrow
Vk_down Arrow key
Vk_select SELECT Key
Vk_execute 2B EXECUTE Key
Vk_snapshot 2C PRINT Screen key (for Windows 3.0 and later versions)
Vk_insert 2D INS Key
Vk_delete 2E DEL Key
Vk_help 2F Help Key
/////////////////////
For numeric and letter keys on a non keypad, just add the key to the single quotation mark.
For example: A key: ' A '
1 keys: ' 1 '
/////////////////////////////////
Vk_lwin 5B left Windows key (Microsoft Natural Keyboard)
Vk_rwin 5C Right Windows key (Microsoft Natural Keyboard)
Vk_apps 5D Applications Key (Microsoft Natural Keyboard)
VK_NUMPAD0 60 numeric keypad with 0 keys
VK_NUMPAD1 61 numeric keypad with 1 keys
VK_NUMPAD2 62 numeric keypad with 2 keys
VK_NUMPAD3 63 numeric keypad with 3 keys
VK_NUMPAD4 64 numeric keypad with 4 keys
VK_NUMPAD5 65 numeric keypad with 5 keys
VK_NUMPAD6 66 Numeric keypad with 6 keys
VK_NUMPAD7 67 Numeric keypad with 7 keys
VK_NUMPAD8 68 numeric keypad with 8 keys
VK_NUMPAD9 69 numeric keypad with 9 keys
Vk_multiply 6A MULTIPLY Key
Vk_add 6B ADD Key
Vk_separator 6C SEPARATOR Key
Vk_subtract 6D Subtract key
Vk_decimal 6E DECIMAL Key
Vk_divide 6F DIVIDE Key
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 7A F11 Key
VK_F12 7B F12 Key
Vk_f13 7C F13 Key
Vk_f14 7D F14 Key
VK_F15 7E F15 Key
VK_F16 7F F16 Key
Vk_f17 80H F17 Key
Vk_f18 81H F18 Key
Vk_f19 82H F19 Key
Vk_f20 83H F20 Key
VK_F21 84H F21 Key
Vk_f22 85H F22 Key
Vk_f23 86H F23 Key
Vk_f24 87H F24 Key
Vk_numlock Num LOCK Key
Vk_scroll SCROLL LOCK Key
VK_ATTN F6 Attn Key
Vk_crsel F7 Crsel Key
Vk_exsel F8 Exsel Key
vk_ereof F9 Erase EOF key
Vk_play FA Play key
Vk_zoom FB ZOOM Key
Vk_oem_clear FE Clear Key
Illustrate the use of these keys:
(a) Respond to individual keystrokes:
Adding PreTranslateMessage () (response Wm_char) is the same effect, because this example captures only the keyboard.
BOOL Cmydilog::P retranslatemessage (msg* pMsg)
{
if (pmsg->message = = Wm_keydown)
{
if (pmsg->wparam== ' M ')//directly using the above virtual code instead, you can respond to the key
MessageBox ("Hello");//If press M key to eject message.
}
Return CDialog::P retranslatemessage (PMSG);
}
(ii) The use of key combinations: (This example responds to the Ctrl+x key)
BOOL Cmydilog::P retranslatemessage (msg* pMsg)
{
if (pmsg->message = = Wm_keydown)
{
Switch (Pmsg->wparam)
{
Case Vk_escape:
SetFocus ();
return TRUE;
Case ' X ':
if (:: Getkeystate (Vk_control) < 0
MessageBox ("Hello");
return TRUE;
}
}
Return CDialog::P retranslatemessage (PMSG);
}