您的位置:首页 > 财经 > 产业 > HID用法ID与按键扫描码对照

HID用法ID与按键扫描码对照

2024/12/23 14:37:49 来源:https://blog.csdn.net/Flame_Cyclone/article/details/142218930  浏览:    关键词:HID用法ID与按键扫描码对照

 整理来源:

// https://learn.microsoft.com/zh-cn/windows/win32/inputdev/about-keyboard-input
// https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input

HID用法名HID用法ID按键扫描码
   A                     0x00040x001E
   B                     0x00050x0030
   C                     0x00060x002E
   D                     0x00070x0020
   E                     0x00080x0012
   F                     0x00090x0021
   G                     0x000A0x0022
   H                     0x000B0x0023
   I                     0x000C0x0017
   J                     0x000D0x0024
   K                     0x000E0x0025
   L                     0x000F0x0026
   M                     0x00100x0032
   N                     0x00110x0031
   O                     0x00120x0018
   P                     0x00130x0019
   Q                     0x00140x0010
   R                     0x00150x0013
   S                     0x00160x001F
   T                     0x00170x0014
   U                     0x00180x0016
   V                     0x00190x002F
   W                     0x001A0x0011
   X                     0x001B0x002D
   Y                     0x001C0x0015
   Z                     0x001D0x002C
   1 & !                 0x001E0x0002
   2 & @                 0x001F0x0003
   3 & #                 0x00200x0004
   4 & $                 0x00210x0005
   5 & %                 0x00220x0006
   6 & ^                 0x00230x0007
   7 & &                 0x00240x0008
   8 & *                 0x00250x0009
   9 & (                 0x00260x000A
   0 & )                 0x00270x000B
   Enter                 0x00280x001C
   Escape                0x00290x0001
   Backspace             0x002A0x000E
   Tab                   0x002B0x000F
   Space                 0x002C0x0039
   - & _                 0x002D0x000C
   = & +                 0x002E0x000D
   [ & {                 0x002F0x001A
   ] & }                 0x00300x001B
   \ & |                0x00310x002B
   ; & :                 0x00330x0027
   ' & "                0x00340x0028
   ` & ~                 0x00350x0029
   , & <                 0x00360x0033
   . & >                 0x00370x0034
   ? & /                 0x00380x0035
   Non-US # & ~          0x00320x002B
   Caps Lock             0x00390x003A
   F1                    0x003A0x003B
   F2                    0x003B0x003C
   F3                    0x003C0x003D
   F4                    0x003D0x003E
   F5                    0x003E0x003F
   F6                    0x003F0x0040
   F7                    0x00400x0041
   F8                    0x00410x0042
   F9                    0x00420x0043
   F10                   0x00430x0044
   F11                   0x00440x0057
   F12                   0x00450x0058
   Print Screen          0x00460xE037
   Sya Req               0x00460x0054
   Scroll Lock             0x00470x0046
   Pause                 0x00480x0045
   Break                 0x00480xE046
   Insert                0x00490xE052
   Home                  0x004A0xE047
   Page Up               0x004B0xE049
   Delete                0x004C0xE053
   End                   0x004D0xE04F
   Page Down             0x004E0xE051
   Right Arrow           0x004F0xE04D
   Left Arrow            0x00500xE04B
   Down Arrow            0x00510xE050
   Up Arrow              0x00520xE048
   Num Lock              0x00530xE045
   Num /                 0x00540xE035
   Num *                 0x00550x0037
   Num -                 0x00560x004A
   Num +                 0x00570x004E
   Num Enter             0x00580xE01C
   Num 1 & End           0x00590x004F
   Num 2 & Down Arrow    0x005A0x0050
   Num 3 & Page Dn       0x005B0x0051
   Num 4 & Left Arrow    0x005C0x004B
   Num 5                 0x005D0x004C
   Num 6 & Right Arrow   0x005E0x004D
   Num 7 & Home          0x005F0x0047
   Num 8 & Up Arrow      0x00600x0048
   Num 9 & Page Up       0x00610x0049
   Num 0 & Insert        0x00620x0052
   Num . & Delete        0x00630x0053
   Non-US /              0x00640x0056
   Application           0x00650xE05D
   Power                 0x00660xE05E
   Keypad =              0x00670x0059
   F13                   0x00680x0064
   F14                   0x00690x0065
   F15                   0x006A0x0066
   F16                   0x006B0x0067
   F17                   0x006C0x0068
   F18                   0x006D0x0069
   F19                   0x006E0x006A
   F20                   0x006F0x006B
   F21                   0x00700x006C
   F22                   0x00710x006D
   F23                   0x00720x006E
   F24                   0x00730x0076
   Left Ctrl             0x00E00x001D
   Left Shift            0x00E10x002A
   Left Alt              0x00E20x0038
   Left Win              0x00E30xE05B
   Right Ctrl            0x00E40xE01D
   Right Shift           0x00E50x0036
   Right Alt             0x00E60xE038
   Right Win             0x00E70xE05C

 C++中使用

#include <windows.h>
#include <string>
#include <stdint.h>
#include <map>
#include <tchar.h>#ifdef _UNICODE
using _tstring = std::wstring;
#else
using _tstring = std::string;
#endiftypedef struct _HID_SCAN_INFO
{_tstring strName;       // 按键名uint8_t nUsageID;       // HID 用法 IDuint16_t nScanCode;     // 扫描码_HID_SCAN_INFO(_tstring _name, uint8_t _id, uint16_t _sc) :strName(_name), nUsageID(_id), nScanCode(_sc){}}HID_SCANCODE_INFO;#define AddHidKeyboardInfo(_name, _id, _sc)   {_T(_name), HID_SCANCODE_INFO(_T(_name), _id, _sc) }// https://learn.microsoft.com/zh-cn/windows/win32/inputdev/about-keyboard-input
// https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input
std::map<_tstring, HID_SCANCODE_INFO> g_mapHidScanOrigin =      //原始映射表(扫描码查询键名使用)
{//AddHidKeyboardInfo("ErrorRollOver",         0x0001, 0x00FF),AddHidKeyboardInfo("A",                     0x0004, 0x001E),AddHidKeyboardInfo("B",                     0x0005, 0x0030),AddHidKeyboardInfo("C",                     0x0006, 0x002E),AddHidKeyboardInfo("D",                     0x0007, 0x0020),AddHidKeyboardInfo("E",                     0x0008, 0x0012),AddHidKeyboardInfo("F",                     0x0009, 0x0021),AddHidKeyboardInfo("G",                     0x000A, 0x0022),AddHidKeyboardInfo("H",                     0x000B, 0x0023),AddHidKeyboardInfo("I",                     0x000C, 0x0017),AddHidKeyboardInfo("J",                     0x000D, 0x0024),AddHidKeyboardInfo("K",                     0x000E, 0x0025),AddHidKeyboardInfo("L",                     0x000F, 0x0026),AddHidKeyboardInfo("M",                     0x0010, 0x0032),AddHidKeyboardInfo("N",                     0x0011, 0x0031),AddHidKeyboardInfo("O",                     0x0012, 0x0018),AddHidKeyboardInfo("P",                     0x0013, 0x0019),AddHidKeyboardInfo("Q",                     0x0014, 0x0010),AddHidKeyboardInfo("R",                     0x0015, 0x0013),AddHidKeyboardInfo("S",                     0x0016, 0x001F),AddHidKeyboardInfo("T",                     0x0017, 0x0014),AddHidKeyboardInfo("U",                     0x0018, 0x0016),AddHidKeyboardInfo("V",                     0x0019, 0x002F),AddHidKeyboardInfo("W",                     0x001A, 0x0011),AddHidKeyboardInfo("X",                     0x001B, 0x002D),AddHidKeyboardInfo("Y",                     0x001C, 0x0015),AddHidKeyboardInfo("Z",                     0x001D, 0x002C),AddHidKeyboardInfo("1 & !",                 0x001E, 0x0002),AddHidKeyboardInfo("2 & @",                 0x001F, 0x0003),AddHidKeyboardInfo("3 & #",                 0x0020, 0x0004),AddHidKeyboardInfo("4 & $",                 0x0021, 0x0005),AddHidKeyboardInfo("5 & %",                 0x0022, 0x0006),AddHidKeyboardInfo("6 & ^",                 0x0023, 0x0007),AddHidKeyboardInfo("7 & &",                 0x0024, 0x0008),AddHidKeyboardInfo("8 & *",                 0x0025, 0x0009),AddHidKeyboardInfo("9 & (",                 0x0026, 0x000A),AddHidKeyboardInfo("0 & )",                 0x0027, 0x000B),AddHidKeyboardInfo("Enter",                 0x0028, 0x001C),AddHidKeyboardInfo("Escape",                0x0029, 0x0001),AddHidKeyboardInfo("Backspace",             0x002A, 0x000E),AddHidKeyboardInfo("Tab",                   0x002B, 0x000F),AddHidKeyboardInfo("Space",                 0x002C, 0x0039),AddHidKeyboardInfo("- & _",                 0x002D, 0x000C),AddHidKeyboardInfo("= & +",                 0x002E, 0x000D),AddHidKeyboardInfo("[ & {",                 0x002F, 0x001A),AddHidKeyboardInfo("] & }",                 0x0030, 0x001B),AddHidKeyboardInfo("\\ & |",                0x0031, 0x002B),AddHidKeyboardInfo("; & :",                 0x0033, 0x0027),AddHidKeyboardInfo("' & \"",                0x0034, 0x0028),AddHidKeyboardInfo("` & ~",                 0x0035, 0x0029),AddHidKeyboardInfo(", & <",                 0x0036, 0x0033),AddHidKeyboardInfo(". & >",                 0x0037, 0x0034),AddHidKeyboardInfo("? & /",                 0x0038, 0x0035),AddHidKeyboardInfo("Non-US # & ~",          0x0032, 0x002B),AddHidKeyboardInfo("Caps Lock",             0x0039, 0x003A),AddHidKeyboardInfo("F1",                    0x003A, 0x003B),AddHidKeyboardInfo("F2",                    0x003B, 0x003C),AddHidKeyboardInfo("F3",                    0x003C, 0x003D),AddHidKeyboardInfo("F4",                    0x003D, 0x003E),AddHidKeyboardInfo("F5",                    0x003E, 0x003F),AddHidKeyboardInfo("F6",                    0x003F, 0x0040),AddHidKeyboardInfo("F7",                    0x0040, 0x0041),AddHidKeyboardInfo("F8",                    0x0041, 0x0042),AddHidKeyboardInfo("F9",                    0x0042, 0x0043),AddHidKeyboardInfo("F10",                   0x0043, 0x0044),AddHidKeyboardInfo("F11",                   0x0044, 0x0057),AddHidKeyboardInfo("F12",                   0x0045, 0x0058),AddHidKeyboardInfo("Print Screen",          0x0046, 0xE037),AddHidKeyboardInfo("Sya Req",               0x0046, 0x0054),AddHidKeyboardInfo("Scroll Lock",           0x0047, 0x0046),  AddHidKeyboardInfo("Pause",                 0x0048, 0x0045),AddHidKeyboardInfo("Break",                 0x0048, 0xE046),AddHidKeyboardInfo("Insert",                0x0049, 0xE052),AddHidKeyboardInfo("Home",                  0x004A, 0xE047),AddHidKeyboardInfo("Page Up",               0x004B, 0xE049),AddHidKeyboardInfo("Delete",                0x004C, 0xE053),AddHidKeyboardInfo("End",                   0x004D, 0xE04F),AddHidKeyboardInfo("Page Down",             0x004E, 0xE051),AddHidKeyboardInfo("Right Arrow",           0x004F, 0xE04D),AddHidKeyboardInfo("Left Arrow",            0x0050, 0xE04B),AddHidKeyboardInfo("Down Arrow",            0x0051, 0xE050),AddHidKeyboardInfo("Up Arrow",              0x0052, 0xE048),AddHidKeyboardInfo("Num Lock",              0x0053, 0xE045),AddHidKeyboardInfo("Num /",                 0x0054, 0xE035),AddHidKeyboardInfo("Num *",                 0x0055, 0x0037),AddHidKeyboardInfo("Num -",                 0x0056, 0x004A),AddHidKeyboardInfo("Num +",                 0x0057, 0x004E),AddHidKeyboardInfo("Num Enter",             0x0058, 0xE01C),AddHidKeyboardInfo("Num 1 & End",           0x0059, 0x004F),AddHidKeyboardInfo("Num 2 & Down Arrow",    0x005A, 0x0050),AddHidKeyboardInfo("Num 3 & Page Dn",       0x005B, 0x0051),AddHidKeyboardInfo("Num 4 & Left Arrow",    0x005C, 0x004B),AddHidKeyboardInfo("Num 5",                 0x005D, 0x004C),AddHidKeyboardInfo("Num 6 & Right Arrow",   0x005E, 0x004D),AddHidKeyboardInfo("Num 7 & Home",          0x005F, 0x0047),AddHidKeyboardInfo("Num 8 & Up Arrow",      0x0060, 0x0048),AddHidKeyboardInfo("Num 9 & Page Up",       0x0061, 0x0049),AddHidKeyboardInfo("Num 0 & Insert",        0x0062, 0x0052),AddHidKeyboardInfo("Num . & Delete",        0x0063, 0x0053),AddHidKeyboardInfo("Non-US /",              0x0064, 0x0056),AddHidKeyboardInfo("Application",           0x0065, 0xE05D),AddHidKeyboardInfo("Power",                 0x0066, 0xE05E),AddHidKeyboardInfo("Keypad =",              0x0067, 0x0059),AddHidKeyboardInfo("F13",                   0x0068, 0x0064),AddHidKeyboardInfo("F14",                   0x0069, 0x0065),AddHidKeyboardInfo("F15",                   0x006A, 0x0066),AddHidKeyboardInfo("F16",                   0x006B, 0x0067),AddHidKeyboardInfo("F17",                   0x006C, 0x0068),AddHidKeyboardInfo("F18",                   0x006D, 0x0069),AddHidKeyboardInfo("F19",                   0x006E, 0x006A),AddHidKeyboardInfo("F20",                   0x006F, 0x006B),AddHidKeyboardInfo("F21",                   0x0070, 0x006C),AddHidKeyboardInfo("F22",                   0x0071, 0x006D),AddHidKeyboardInfo("F23",                   0x0072, 0x006E),AddHidKeyboardInfo("F24",                   0x0073, 0x0076),AddHidKeyboardInfo("Left Ctrl",             0x00E0, 0x001D),AddHidKeyboardInfo("Left Shift",            0x00E1, 0x002A),AddHidKeyboardInfo("Left Alt",              0x00E2, 0x0038),AddHidKeyboardInfo("Left Win",              0x00E3, 0xE05B),AddHidKeyboardInfo("Right Ctrl",            0x00E4, 0xE01D),AddHidKeyboardInfo("Right Shift ",          0x00E5, 0x0036),AddHidKeyboardInfo("Right Alt",             0x00E6, 0xE038),AddHidKeyboardInfo("Right Win",             0x00E7, 0xE05C),
};

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com