USB鼠标键盘数据格式以及按键键值

鼠标发送给PC的数据每次4个字节 
BYTE1 BYTE2 BYTE3 BYTE4 
定义分别是: 
BYTE1 -- 
       |--bit7:   1   表示   Y   坐标的变化量超出-256   ~   255的范围,0表示没有溢出  
       |--bit6:   1   表示   X   坐标的变化量超出-256   ~   255的范围,0表示没有溢出  
       |--bit5:   Y   坐标变化的符号位,1表示负数,即鼠标向下移动  
       |--bit4:   X   坐标变化的符号位,1表示负数,即鼠标向左移动  
       |--bit3:     恒为1  
       |--bit2:     1表示中键按下  
       |--bit1:     1表示右键按下  
       |--bit0:     1表示左键按下  
BYTE2 -- X坐标变化量,与byte的bit4组成9位符号数,负数表示向左移,正数表右移。用补码表示变化量  
BYTE3 -- Y坐标变化量,与byte的bit5组成9位符号数,负数表示向下移,正数表上移。用补码表示变化量 
BYTE4 -- 滚轮变化。 
由于手上没有USB鼠标,对BYTE1的4-7位没有测试,对于BYTE2 BYTE3做个测试,BYTE1的4-7全为0的时候,BYTE2 BYTE3的正负表示鼠标移动方向

键盘发送给PC的数据每次8个字节 
BYTE1 BYTE2 BYTE3 BYTE4 BYTE5 BYTE6 BYTE7 BYTE8 
定义分别是: 
BYTE1 -- 
       |--bit0:   Left Control是否按下,按下为1  
       |--bit1:   Left Shift  是否按下,按下为1  
       |--bit2:   Left Alt    是否按下,按下为1  
       |--bit3:   Left GUI    是否按下,按下为1  
       |--bit4:   Right Control是否按下,按下为1   
       |--bit5:   Right Shift 是否按下,按下为1  
       |--bit6:   Right Alt   是否按下,按下为1  
       |--bit7:   Right GUI   是否按下,按下为1  
BYTE2 -- 暂不清楚,有的地方说是保留位 
BYTE3--BYTE8 -- 这六个为普通按键 
键盘经过测试。 
例如:键盘发送一帧数据   02 00 0x04 0x05 00 00 00 00 
表示同时按下了Left Shift + ‘a’+‘b’三个键

第一列10进制键值,第二列16进制键值,第四列是按键

  Reserved (no event indicated) N/A √ √ √ //
Keyboard ErrorRollOver9 N/A √ √ √ //
Keyboard POSTFail9 N/A √ √ √ //
Keyboard ErrorUndefined9 N/A √ √ √ //
Keyboard a and A4 √ √ √ //
Keyboard b and B √ √ √ //
Keyboard c and C4 √ √ √ //
Keyboard d and D √ √ √ //
Keyboard e and E √ √ √ //
Keyboard f and F √ √ √ //
0A Keyboard g and G √ √ √ //
0B Keyboard h and H √ √ √ //
0C Keyboard i and I √ √ √ //
0D Keyboard j and J √ √ √ //
0E Keyboard k and K √ √ √ //
0F Keyboard l and L √ √ √ //
Keyboard m and M4 √ √ √ //
Keyboard n and N √ √ √ //
Keyboard o and O4 √ √ √ //
Keyboard p and P4 √ √ √ //
Keyboard q and Q4 √ √ √ //
Keyboard r and R √ √ √ //
Keyboard s and S4 √ √ √ //
Keyboard t and T √ √ √ //
Keyboard u and U √ √ √ //
Keyboard v and V √ √ √ //
1A Keyboard w and W4 √ √ √ //
1B Keyboard x and X4 √ √ √ //
1C Keyboard y and Y4 √ √ √ //
1D Keyboard z and Z4 √ √ √ //
1E Keyboard and ! √ √ √ //
1F Keyboard and @ √ √ √ //
Keyboard and # √ √ √ //
Keyboard and $ √ √ √ //
Keyboard and % √ √ √ //
Keyboard and ^ √ √ √ //
Keyboard and & √ √ √ //
Keyboard and * √ √ √ //
Keyboard and ( √ √ √ //
Keyboard and ) √ √ √ //
Keyboard Return (ENTER) √ √ √ //
Keyboard ESCAPE √ √ √ //
2A Keyboard DELETE (Backspace) √ √ √ //
2B Keyboard Tab √ √ √ //
2C Keyboard Spacebar √ √ √ //
2D Keyboard - and (underscore) √ √ √ //
2E Keyboard = and + √ √ √ //
2F Keyboard [ and { √ √ √ //
Keyboard ] and } √ √ √ //
Keyboard \ and | √ √ √ //
Keyboard Non-US # and ~ √ √ √ //
Keyboard ; and : √ √ √ //
Keyboard ‘ and “ √ √ √ //
Keyboard Grave Accent and Tilde4 √ √ √ //
Keyboard, and < √ √ √ //
Keyboard . and > √ √ √ //
Keyboard / and ? √ √ √ //
Keyboard Caps Lock11 √ √ √ //
3A Keyboard F1 √ √ √ //
3B Keyboard F2 √ √ √ //
3C Keyboard F3 √ √ √ //
3D Keyboard F4 √ √ √ //
3E Keyboard F5 √ √ √ //
3F Keyboard F6 √ √ √ //
Keyboard F7 √ √ √ //
Keyboard F8 √ √ √ //
Keyboard F9 √ √ √ //
Keyboard F10 √ √ √ //
Keyboard F11 √ √ √ /
Keyboard F12 √ √ √ /
Keyboard PrintScreen1 √ √ √ /
Keyboard Scroll Lock11 √ √ √ //
Keyboard Pause1 √ √ √ /
Keyboard Insert1 √ √ √ /
4A Keyboard Home1 √ √ √ /
4B Keyboard PageUp1 √ √ √ /
4C Keyboard Delete Forward1; √ √ √ /
4D Keyboard End1 √ √ √ /
4E Keyboard PageDown1 √ √ √ /
4F Keyboard RightArrow1 √ √ √ /
Keyboard LeftArrow1 √ √ √ /
Keyboard DownArrow1 √ √ √ /
Keyboard UpArrow1 √ √ √ /
Keypad Num Lock and Clear11 √ √ √ /
Keypad / √ √ √ /
Keypad * √ √ √ //
Keypad - √ √ √ //
Keypad + √ √ √ //
Keypad ENTER5 √ √ √ /
Keypad and End √ √ √ //
5A Keypad and Down Arrow √ √ √ //
5B Keypad and PageDn √ √ √ //
5C Keypad and Left Arrow √ √ √ //
5D Keypad √ √ √ //
5E Keypad and Right Arrow √ √ √ //
5F Keypad and Home √ √ √ //
Keypad and Up Arrow √ √ √ //
Keypad and PageUp √ √ √ //
Keypad and Insert √ √ √ //
Keypad . and Delete √ √ √ //
Keyboard Non-US \ and |; √ √ √ //
Keyboard Application10 √ √
Keyboard Power9 √ √
Keypad = √
Keyboard F13 √
Keyboard F14 √
6A Keyboard F15 √
6B Keyboard F16
6C Keyboard F17
6D Keyboard F18
6E Keyboard F19
6F Keyboard F20
Keyboard F21
Keyboard F22
Keyboard F23
Keyboard F24
Keyboard Execute √
Keyboard Help √
Keyboard Menu √
Keyboard Select √
Keyboard Stop √
Keyboard Again √
7A Keyboard Undo √
7B Keyboard Cut √
7C Keyboard Copy √
7D Keyboard Paste √
7E Keyboard Find √
7F Keyboard Mute √
Keyboard Volume Up √
Keyboard Volume Down √
Keyboard Locking Caps Lock12 √
Keyboard Locking Num Lock12 √
Keyboard Locking Scroll Lock12 √
Keypad Comma27
Keypad Equal Sign29
Keyboard International115,
Keyboard International216
Keyboard International317
8A Keyboard International418
8B Keyboard International519
8C Keyboard International620
8D Keyboard International721
8E Keyboard International822
8F Keyboard International922
Keyboard LANG125
Keyboard LANG226
Keyboard LANG330
Keyboard LANG431
Keyboard LANG532
Keyboard LANG68
Keyboard LANG78
Keyboard LANG88
Keyboard LANG98
Keyboard Alternate Erase7
9A Keyboard SysReq/Attention1
9B Keyboard Cancel
9C Keyboard Clear
9D Keyboard Prior
9E Keyboard Return
9F Keyboard Separator
A0 Keyboard Out
A1 Keyboard Oper
A2 Keyboard Clear/Again
A3 Keyboard CrSel/Props
A4 Keyboard ExSel
- A5-CF Reserved
B0 Keypad
B1 Keypad
B2 Thousands Separator
B3 Decimal Separator
B4 Currency Unit
B5 Currency Sub-unit
B6 Keypad (
B7 Keypad )
B8 Keypad {
B9 Keypad }
BA Keypad Tab
BB Keypad Backspace
BC Keypad A
BD Keypad B
BE Keypad C
BF Keypad D
C0 Keypad E
C1 Keypad F
C2 Keypad XOR
C3 Keypad ^
C4 Keypad %
C5 Keypad <
C6 Keypad >
C7 Keypad &
C8 Keypad &&
C9 Keypad |
CA Keypad ||
CB Keypad :
CC Keypad #
CD Keypad Space
CE Keypad @
CF Keypad !
D0 Keypad Memory Store
D1 Keypad Memory Recall
D2 Keypad Memory Clear
D3 Keypad Memory Add
D4 Keypad Memory Subtract
D5 Keypad Memory Multiply
D6 Keypad Memory Divide
D7 Keypad +/-
D8 Keypad Clear
D9 Keypad Clear Entry
DA Keypad Binary
DB Keypad Octal
DC Keypad Decimal
DD Keypad Hexadecimal
- DE-DF Reserved
E0 Keyboard LeftControl √ √ √ //
E1 Keyboard LeftShift √ √ √ //
E2 Keyboard LeftAlt √ √ √ //
E3 Keyboard Left GUI10; √ √ √
E4 Keyboard RightControl √ √ √ /
E5 Keyboard RightShift √ √ √ //
E6 Keyboard RightAlt √ √ √ /
E7 Keyboard Right GUI10; √ √ √
- E8-FFFF Reserved

点击链接加入群聊【西安电子开发交流群】:https://jq.qq.com/?_wv=1027&k=5MjknoT

<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=b198731df64742fda8d6948036eb6fd199b1994bb010f2362402c78cd3169c0d"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="西安电子开发交流群" title="西安电子开发交流群"></a>

上一篇:转:jQuery插件之Wookmark:流布局插件遇到图片资源请求过慢导致最终计算图片绝对位置top不够准确发生图片重叠的解决方案


下一篇:CPU频率