键盘事件的代码值
下表显示了在主要平台上每个原生扫描码或虚拟键盘码使用的代码值。原因是一些浏览器选择以不同的方式解释物理键,在哪些键映射到哪些代码方面存在一些差异。这些表格显示了已知的这些差异。
Windows 上的代码值
此表显示了代表键的 Windows 扫描代码以及与这些硬件键对应的KeyboardEvent.code
值。仅列出在 Windows 上生成扫描代码的键。
在单元格中,“(❌ 缺失)”表示此代码值在此浏览器中无法检测到;“(⚠️ 在 xyz 上不相同)”表示此字符串在浏览器 xyz 上表示不同的代码值,并且在使用它时必须格外小心。
KeyboardEvent.code 值 |
||
---|---|---|
代码 | Firefox | Chrome |
0x0000 |
|
"" |
0x0001 |
"Escape" |
"Escape" |
0x0002 |
"Digit1" |
"Digit1" |
0x0003 |
"Digit2" |
"Digit2" |
0x0004 |
"Digit3" |
"Digit3" |
0x0005 |
"Digit4" |
"Digit4" |
0x0006 |
"Digit5" |
"Digit5" |
0x0007 |
"Digit6" |
"Digit6" |
0x0008 |
"Digit7" |
"Digit7" |
0x0009 |
"Digit8" |
"Digit8" |
0x000A |
"Digit9" |
"Digit9" |
0x000B |
"Digit0" |
"Digit0" |
0x000C |
"Minus" |
"Minus" |
0x000D |
"Equal" |
"Equal" |
0x000E |
"Backspace" |
"Backspace" |
0x000F |
"Tab" |
"Tab" |
0x0010 |
"KeyQ" |
"KeyQ" |
0x0011 |
"KeyW" |
"KeyW" |
0x0012 |
"KeyE" |
"KeyE" |
0x0013 |
"KeyR" |
"KeyR" |
0x0014 |
"KeyT" |
"KeyT" |
0x0015 |
"KeyY" |
"KeyY" |
0x0016 |
"KeyU" |
"KeyU" |
0x0017 |
"KeyI" |
"KeyI" |
0x0018 |
"KeyO" |
"KeyO" |
0x0019 |
"KeyP" |
"KeyP" |
0x001A |
"BracketLeft" |
"BracketLeft" |
0x001B |
"BracketRight" |
"BracketRight" |
0x001C |
"Enter" |
"Enter" |
0x001D |
"ControlLeft" |
"ControlLeft" |
0x001E |
"KeyA" |
"KeyA" |
0x001F |
"KeyS" |
"KeyS" |
0x0020 |
"KeyD" |
"KeyD" |
0x0021 |
"KeyF" |
"KeyF" |
0x0022 |
"KeyG" |
"KeyG" |
0x0023 |
"KeyH" |
"KeyH" |
0x0024 |
"KeyJ" |
"KeyJ" |
0x0025 |
"KeyK" |
"KeyK" |
0x0026 |
"KeyL" |
"KeyL" |
0x0027 |
"Semicolon" |
"Semicolon" |
0x0028 |
"Quote" |
"Quote" |
0x0029 |
"Backquote" |
"Backquote" |
0x002A |
"ShiftLeft" |
"ShiftLeft" |
0x002B |
"Backslash" |
"Backslash" |
0x002C |
"KeyZ" |
"KeyZ" |
0x002D |
"KeyX" |
"KeyX" |
0x002E |
"KeyC" |
"KeyC" |
0x002F |
"KeyV" |
"KeyV" |
0x0030 |
"KeyB" |
"KeyB" |
0x0031 |
"KeyN" |
"KeyN" |
0x0032 |
"KeyM" |
"KeyM" |
0x0033 |
"Comma" |
"Comma" |
0x0034 |
"Period" |
"Period" |
0x0035 |
"Slash" |
"Slash" |
0x0036 |
"ShiftRight" |
"ShiftRight" |
0x0037 |
"NumpadMultiply" |
"NumpadMultiply" |
0x0038 |
"AltLeft" |
"AltLeft" |
0x0039 |
"Space" |
"Space" |
0x003A |
"CapsLock" |
"CapsLock" |
0x003B |
"F1" |
"F1" |
0x003C |
"F2" |
"F2" |
0x003D |
"F3" |
"F3" |
0x003E |
"F4" |
"F4" |
0x003F |
"F5" |
"F5" |
0x0040 |
"F6" |
"F6" |
0x0041 |
"F7" |
"F7" |
0x0042 |
"F8" |
"F8" |
0x0043 |
"F9" |
"F9" |
0x0044 |
"F10" |
"F10" |
0x0045 |
"Pause" |
"Pause" |
0x0046 |
"ScrollLock" |
"ScrollLock" |
0x0047 |
"Numpad7" |
"Numpad7" |
0x0048 |
"Numpad8" |
"Numpad8" |
0x0049 |
"Numpad9" |
"Numpad9" |
0x004A |
"NumpadSubtract" |
"NumpadSubtract" |
0x004B |
"Numpad4" |
"Numpad4" |
0x004C |
"Numpad5" |
"Numpad5" |
0x004D |
"Numpad6" |
"Numpad6" |
0x004E |
"NumpadAdd" |
"NumpadAdd" |
0x004F |
"Numpad1" |
"Numpad1" |
0x0050 |
"Numpad2" |
"Numpad2" |
0x0051 |
"Numpad3" |
"Numpad3" |
0x0052 |
"Numpad0" |
"Numpad0" |
0x0053 |
"NumpadDecimal" |
"NumpadDecimal" |
0x0054 (Alt + PrintScreen) |
"PrintScreen" (⚠️ 在 Chrome 上不相同) |
"" (❌ 缺失) |
0x0055 |
"Unidentified" |
"" |
0x0056 |
"IntlBackslash" |
"IntlBackslash" |
0x0057 |
"F11" |
"F11" |
0x0058 |
"F12" |
"F12" |
0x0059 |
"NumpadEqual" |
"NumpadEqual" (在 Chrome 48 之前为 "" ) |
0x005A |
"Unidentified" |
"" |
0x005B |
"Unidentified" |
"" (在 Chrome 48 之前为 "F13" ) |
0x005C |
"Unidentified" |
"" (在 Chrome 48 之前为 "F14" ) |
0x005D |
"Unidentified" |
"" (在 Chrome 48 之前为 "F15" ) |
0x005E |
"Unidentified" |
"" |
0x005F |
"Unidentified" |
"" |
0x0060 |
"Unidentified" |
"" |
0x0061 |
"Unidentified" |
"" |
0x0062 |
"Unidentified" |
"" |
0x0063 |
"Unidentified" |
"" (在 Chrome 48 之前为 "F16" ) |
0x0064 |
"F13" |
"F13" (在 Chrome 48 之前为 "F17" ) |
0x0065 |
"F14" |
"F14" (在 Chrome 48 之前为 "F18" ) |
0x0066 |
"F15" |
"F15" (在 Chrome 48 之前为 "F19" ) |
0x0067 |
"F16" |
"F16" (在 Chrome 48 之前为 "F20" ) |
0x0068 |
"F17" |
"F17" (在 Chrome 48 之前为 "F21" ) |
0x0069 |
"F18" |
"F18" (在 Chrome 48 之前为 "F22" ) |
0x006A |
"F19" |
"F19" (在 Chrome 48 之前为 "F23" ) |
0x006B |
"F20" |
"F20" (在 Chrome 48 之前为 "F24" ) |
0x006C |
"F21" |
"F21" (在 Chrome 48 之前为 "" ) |
0x006D |
"F22" |
"F22" (在 Chrome 48 之前为 "" ) |
0x006E |
"F23" |
"F23" (在 Chrome 48 之前为 "" ) |
0x006F |
"Unidentified" |
"" |
0x0070 |
"KanaMode" |
"KanaMode" (在 Chrome 48 之前为 "" ) |
0x0071 (Hanja 键,无韩语键盘布局) |
"Lang2" |
"Lang2" (在 Chrome 48 之前为 "" ) |
0x0072 (Han/Yeong 键,无韩语键盘布局) |
"Lang1" |
"Lang1" (在 Chrome 48 之前为 "" ) |
0x0073 |
"IntlRo" |
"IntlRo" (在 Chrome 48 之前为 "" ) |
0x0074 , 0x0075 |
"Unidentified" |
"" |
0x0076 |
"F24" |
"F24" (在 Chrome 48 之前为 "" ) |
0x0077 |
"Unidentified" (❌ 缺失) |
"Lang4" (在 Chrome 48 之前为 "" ) (⚠️ 在 Firefox 上不相同) |
0x0078 |
"Unidentified" (❌ 缺失) |
"Lang3" (在 Chrome 48 之前为 "" ) (⚠️ 在 Firefox 上不相同) |
0x0079 |
"Convert" |
"Convert" (在 Chrome 48 之前为 "" ) |
0x007A |
"Unidentified" |
"" |
0x007B |
"NonConvert" |
"NonConvert" (在 Chrome 48 之前为 "" ) |
0x007C |
"Unidentified" |
"" |
0x007D |
"IntlYen" |
"IntlYen" |
0x007E |
"NumpadComma" |
"NumpadComma" (在 Chrome 48 之前为 "" ) |
0x007F |
"Unidentified" |
"" |
0xE000 ~ 0xE007 |
"Unidentified" |
"" |
0xE008 |
"Unidentified" (❌ 缺失) |
"Undo" (⚠️ 在 Firefox 上不相同) |
0xE009 |
"Unidentified" |
"" |
0xE00A |
"" (❌ 缺失) |
"Paste" (⚠️ 在 Firefox 上不相同) |
0xE00B ~ 0xE00F |
"" | "" |
0xE010 |
"MediaTrackPrevious" |
"MediaTrackPrevious" |
0xE011 ~ 0xE016 |
"" |
"" |
0xE017 |
"Unidentified" (❌ 缺失) |
"Cut" (⚠️ 在 Firefox 上不相同) |
0xE018 |
"Unidentified" (❌ 缺失) |
"Copy" (⚠️ 在 Firefox 上不相同) |
0xE019 |
"MediaTrackNext" |
"MediaTrackNext" |
0xE01A, 0xE01B |
"Unidentified" |
"" |
0xE01C |
"NumpadEnter" |
"NumpadEnter" |
0xE01D |
"ControlRight" |
"ControlRight" |
0xE01E |
"Unidentified" |
"" (在 Chrome 48 之前为 "LaunchMail" ) |
0xE01F |
"Unidentified" |
"" |
0xE020 |
"AudioVolumeMute" |
"AudioVolumeMute" |
0xE021 |
"LaunchApp2" |
"LaunchApp2" (在 Chrome 48 之前为 "" ) |
0xE022 |
"MediaPlayPause" |
"MediaPlayPause" |
0xE023 |
"Unidentified" |
"" |
0xE024 |
"MediaStop" |
"MediaStop" |
0xE025 ~ 0xE02B |
"Unidentified" |
"" |
0xE02C |
"Unidentified" (❌ 缺失) |
"Eject" (⚠️ 在 Firefox 上不相同) |
0xE02D |
"Unidentified" |
"" |
0xE02E |
"VolumeDown" (⚠️ 在 Chrome 上不相同) |
"AudioVolumeDown" (在 Chrome 52 之前为 "VolumeDown" ) (⚠️ 在 Firefox 上不相同) |
0xE02F |
"Unidentified" |
"" |
0xE030 |
"VolumeUp" (⚠️ 在 Chrome 上不相同) |
"AudioVolumeUp" (在 Chrome 52 之前为 "VolumeUp" ) (⚠️ 在 Firefox 上不相同) |
0xE031 |
"Unidentified" |
"" |
0xE032 |
"BrowserHome" |
"BrowserHome" |
0xE033 , 0xE034 |
"Unidentified" |
"" |
0xE035 |
"NumpadDivide" |
"NumpadDivide" |
0xE036 |
"Unidentified" |
"" |
0xE037 |
"PrintScreen" |
"PrintScreen" |
0xE038 |
"AltRight" |
"AltRight" |
0xE039 , 0xE03A |
"Unidentified" |
"" |
0xE03B |
"Unidentified" (❌ 缺失) |
"Help" (⚠️ 在 Firefox 上不相同) |
0xE03C ~ 0xE044 |
"Unidentified" |
"" |
0xE045 |
"NumLock"
|
"NumLock"
|
0xE046 (Ctrl + 暂停) |
"Pause" |
"Pause" |
0xE047 |
"Home" |
"Home" |
0xE048 |
"向上箭头" |
"向上箭头" |
0xE049 |
"PageUp" |
"PageUp" |
0xE04A |
"Unidentified" |
"" |
0xE04B |
"向左箭头" |
"向左箭头" |
0xE04C |
"Unidentified" |
"" |
0xE04D |
"向右箭头" |
"向右箭头" |
0xE04E |
"Unidentified" |
"" |
0xE04F |
"End" |
"End" |
0xE050 |
"向下箭头" |
"向下箭头" |
0xE051 |
"PageDown" |
"PageDown" |
0xE052 |
"Insert" |
"Insert" |
0xE053 |
"Delete" |
"Delete" |
0xE054 ~ 0xE05A |
"Unidentified" |
"" |
0xE05B |
"MetaLeft" (Firefox 118 之前版本为 "OSLeft" ) |
"MetaLeft" (Chrome 52 之前版本为 "OSLeft" ) |
0xE05C |
"MetaRight" (Firefox 118 之前版本为 "OSRight" ) |
"MetaRight" (Chrome 52 之前版本为 "OSRight" ) |
0xE05D |
"ContextMenu" |
"ContextMenu" |
0xE05E |
"电源" |
"Power" (Chrome 48 之前版本为 "" ) |
0xE05F |
"Unidentified" (❌ 缺失) |
"Sleep" (Chrome 48 之前版本为 "" ) (⚠️ Firefox 上有所不同) |
0xE060 ~ 0xE062 |
"Unidentified" |
"" |
0xE063 |
"Unidentified" (❌ 缺失) |
"WakeUp" (Chrome 48 之前版本为 "" ) (⚠️ Firefox 上有所不同) |
0xE064 |
"Unidentified" |
"" |
0xE065 |
"浏览器搜索" |
"浏览器搜索" |
0xE066 |
"浏览器收藏夹" |
"浏览器收藏夹" |
0xE067 |
"浏览器刷新" |
"浏览器刷新" |
0xE068 |
"浏览器停止" |
"浏览器停止" |
0xE069 |
"浏览器前进" |
"浏览器前进" |
0xE06A |
"浏览器后退" |
"浏览器后退" |
0xE06B |
"启动应用1" |
"LaunchApp1" (Chrome 48 之前版本为 "" ) |
0xE06C |
"启动邮件" |
"LaunchMail" (Chrome 48 之前版本为 "" ) |
0xE06D |
"媒体选择" |
"MediaSelect" (Chrome 48 之前版本为 "" ) |
0xE06E ~ 0xE0F0 |
"Unidentified" |
"" |
0xE0F1 (韩字 键,使用韩国键盘布局) |
"Lang2" (⚠️ Chrome 上有所不同) |
"" (❌ 缺失) |
0xE0F2 (韩/英 键,使用韩国键盘布局) |
"Lang1" (⚠️ Chrome 上有所不同) |
"" (❌ 缺失) |
Mac 上的代码值
在 macOS 上,很难获取扫描码或其他可以区分物理按键和按键事件的内容。因此,Firefox 始终从虚拟键码映射 code
值。
在单元格中,
- "(❌ 缺失)" 表示此代码值在此浏览器中无法检测到;
- "(⚠️ xyz 上有所不同)" 表示此字符串在浏览器 xyz 上表示不同的代码值,使用时需要特别注意;
- "(⚠️ 与
0xab
字符串相同)" 表示无法区分此按键与匹配0xab
的按键; - "(⚠️ 实际上未触发事件)" 表示即使从技术上讲此代码具有特定的字符串,也不会分派事件;
虚拟键码 | Firefox | Chromium |
---|---|---|
kVK_ANSI_A (0x00) |
"KeyA" |
"KeyA" |
kVK_ANSI_S (0x01) |
"KeyS" |
"KeyS" |
kVK_ANSI_D (0x02) |
"KeyD" |
"KeyD" |
kVK_ANSI_F (0x03) |
"KeyF" |
"KeyF" |
kVK_ANSI_H (0x04) |
"KeyH" |
"KeyH" |
kVK_ANSI_G (0x05) |
"KeyG" |
"KeyG" |
kVK_ANSI_Z (0x06) |
"KeyZ" |
"KeyZ" |
kVK_ANSI_X (0x07) |
"KeyX" |
"KeyX" |
kVK_ANSI_C (0x08) |
"KeyC" |
"KeyC" |
kVK_ANSI_V (0x09) |
"KeyV" |
"KeyV" |
kVK_ISO_Section (0x0A) |
"IntlBackslash" |
"IntlBackslash" |
kVK_ANSI_B (0x0B) |
"KeyB" |
"KeyB" |
kVK_ANSI_Q (0x0C) |
"KeyQ" |
"KeyQ" |
kVK_ANSI_W (0x0D) |
"KeyW" |
"KeyW" |
kVK_ANSI_E (0x0E) |
"KeyE" |
"KeyE" |
kVK_ANSI_R (0x0F) |
"KeyR" |
"KeyR" |
kVK_ANSI_Y (0x10) |
"KeyY" |
"KeyY" |
kVK_ANSI_T (0x11) |
"KeyT" |
"KeyT" |
kVK_ANSI_1 (0x12) |
"Digit1" |
"Digit1" |
kVK_ANSI_2 (0x13) |
"Digit2" |
"Digit2" |
kVK_ANSI_3 (0x14) |
"Digit3" |
"Digit3" |
kVK_ANSI_4 (0x15) |
"Digit4" |
"Digit4" |
kVK_ANSI_6 (0x16) |
"Digit6" |
"Digit6" |
kVK_ANSI_5 (0x17) |
"Digit5" |
"Digit5" |
kVK_ANSI_Equal (0x18) |
"Equal" |
"Equal" |
kVK_ANSI_9 (0x19) |
"Digit9" |
"Digit9" |
kVK_ANSI_7 (0x1A) |
"Digit7" |
"Digit7" |
kVK_ANSI_Minus (0x1B) |
"Minus" |
"Minus" |
kVK_ANSI_8 (0x1C) |
"Digit8" |
"Digit8" |
kVK_ANSI_0 (0x1D) |
"Digit0" |
"Digit0" |
kVK_ANSI_RightBracket (0x1E) |
"BracketRight" |
"BracketRight" |
kVK_ANSI_O (0x1F) |
"KeyO" |
"KeyO" |
kVK_ANSI_U (0x20) |
"KeyU" |
"KeyU" |
kVK_ANSI_LeftBracket (0x21) |
"BracketLeft" |
"BracketLeft" |
kVK_ANSI_I (0x22) |
"KeyI" |
"KeyI" |
kVK_ANSI_P (0x23) |
"KeyP" |
"KeyP" |
kVK_Return (0x24) |
"Enter" |
"Enter" |
kVK_ANSI_L (0x25) |
"KeyL" |
"KeyL" |
kVK_ANSI_J (0x26) |
"KeyJ" |
"KeyJ" |
kVK_ANSI_Quote (0x27) |
"Quote" |
"Quote" |
kVK_ANSI_K (0x28) |
"KeyK" |
"KeyK" |
kVK_ANSI_Semicolon (0x29) |
"Semicolon" |
"Semicolon" |
kVK_ANSI_Backslash (0x2A) |
"Backslash" |
"Backslash" |
kVK_ANSI_Comma (0x2B) |
"Comma" |
"Comma" |
kVK_ANSI_Slash (0x2C) |
"Slash" |
"Slash" |
kVK_ANSI_N (0x2D) |
"KeyN" |
"KeyN" |
kVK_ANSI_M (0x2E) |
"KeyM" |
"KeyM" |
kVK_ANSI_Period (0x2F) |
"Period" |
"Period" |
kVK_Tab (0x30) |
"Tab" |
"Tab" |
kVK_Space (0x31) |
"Space" |
"Space" |
kVK_ANSI_Grave (0x32) |
"Backquote" |
"Backquote" |
kVK_Delete (0x33) |
"Backspace" |
"Backspace" |
PowerBook 键盘上的 Enter 键 (0x34 ) |
"NumpadEnter" (⚠️ 与 0x4C 字符串相同) (⚠️ Chromium 上有所不同) |
"" (❌ 缺失) |
kVK_Escape (0x35) |
"Escape" |
"Escape" |
右 Command 键 (0x36 ) |
"MetaRight" (Firefox 118 之前版本为 "OSRight" ) |
"MetaRight" (Chromium 52 之前版本为 "OSRight" ) |
kVK_Command (0x37) |
"MetaLeft" (Firefox 118 之前版本为 "OSLeft" ) |
"MetaLeft" (Chromium 52 之前版本为 "OSLeft" ) |
kVK_Shift (0x38) |
"ShiftLeft" |
"ShiftLeft" |
kVK_CapsLock (0x39) |
"CapsLock" |
"CapsLock" |
kVK_Option (0x3A) |
"AltLeft" |
"AltLeft" |
kVK_Control (0x3B) |
"ControlLeft" |
"ControlLeft" |
kVK_RightShift (0x3C) |
"ShiftRight" |
"ShiftRight" |
kVK_RightOption (0x3D) |
"AltRight" |
"AltRight" |
kVK_RightControl (0x3E) |
"ControlRight" |
"ControlRight" |
kVK_Function (0x3F) |
"Fn" (⚠️ 实际上未触发事件) |
"" (❌ 缺失) (⚠️ 实际上未触发事件) |
kVK_F17 (0x40) |
"F17" |
"F17" |
kVK_ANSI_KeypadDecimal (0x41) |
"NumpadDecimal" |
"NumpadDecimal" |
kVK_ANSI_KeypadMultiply (0x43) |
"NumpadMultiply" |
"NumpadMultiply" |
kVK_ANSI_KeypadPlus (0x45) |
"NumpadAdd" |
"NumpadAdd" |
kVK_ANSI_KeypadClear (0x47) |
"NumLock"
|
"NumLock"
|
kVK_VolumeUp (0x48) |
"VolumeUp" (⚠️ Chromium 上有所不同) |
"AudioVolumeUp" (Chromium 1 之前版本为 "VolumeUp" ) (⚠️ Firefox 上有所不同) |
kVK_VolumeDown (0x49) |
"VolumeDown" (⚠️ Chromium 上有所不同) |
"AudioVolumeDown" (Chromium 52 之前版本为 "VolumeDown" ) (⚠️ Firefox 上有所不同) |
kVK_Mute (0x4A) |
"VolumeMute" (⚠️ Chromium 上有所不同) |
"AudioVolumeMute" (Chromium 52 之前版本为 "VolumeMute" ) (⚠️ Firefox 上有所不同) |
kVK_ANSI_KeypadDivide (0x4B) |
"NumpadDivide" |
"NumpadDivide" |
kVK_ANSI_KeypadEnter (0x4C) |
"NumpadEnter" |
"NumpadEnter" |
kVK_ANSI_KeypadMinus (0x4E) |
"NumpadSubtract" |
"NumpadSubtract" |
kVK_F18 (0x4F) |
"F18" |
"F18" |
kVK_F19 (0x50) |
"F19" |
"F19" |
kVK_ANSI_KeypadEquals (0x51) |
"NumpadEqual" |
"NumpadEqual" |
kVK_ANSI_Keypad0 (0x52) |
"Numpad0" |
"Numpad0" |
kVK_ANSI_Keypad1 (0x53) |
"Numpad1" |
"Numpad1" |
kVK_ANSI_Keypad2 (0x54) |
"Numpad2" |
"Numpad2" |
kVK_ANSI_Keypad3 (0x55) |
"Numpad3" |
"Numpad3" |
kVK_ANSI_Keypad4 (0x56) |
"Numpad4" |
"Numpad4" |
kVK_ANSI_Keypad5 (0x57) |
"Numpad5" |
"Numpad5" |
kVK_ANSI_Keypad6 (0x58) |
"Numpad6" |
"Numpad6" |
kVK_ANSI_Keypad7 (0x59) |
"Numpad7" |
"Numpad7" |
kVK_F20 (0x5A) |
"F20" |
"F20" |
kVK_ANSI_Keypad8 (0x5B) |
"Numpad8" |
"Numpad8" |
kVK_ANSI_Keypad9 (0x5C) |
"Numpad9" |
"Numpad9" |
kVK_JIS_Yen (0x5D) |
"IntlYen" |
"IntlYen" |
kVK_JIS_Underscore (0x5E) |
"IntlRo" |
"IntlRo" |
kVK_JIS_KeypadComma (0x5F) |
"NumpadComma" |
"NumpadComma" |
kVK_F5 (0x60) |
"F5" |
"F5" |
kVK_F6 (0x61) |
"F6" |
"F6" |
kVK_F7 (0x62) |
"F7" |
"F7" |
kVK_F3 (0x63) |
"F3" |
"F3" |
kVK_F8 (0x64) |
"F8" |
"F8" |
kVK_F9 (0x65) |
"F9" |
"F9" |
kVK_JIS_Eisu (0x66) |
"Lang2" |
"Lang2" (Chromium 82 之前版本为 "" ) (⚠️ 实际上未触发事件) |
kVK_F11 (0x67) |
"F11" |
"F11" |
kVK_JIS_Kana (0x68) |
"Lang1" |
"Lang1" (Chromium 82 之前版本为 "KanaMode" ) (⚠️ 实际上未触发事件) |
kVK_F13 (0x69) |
"F13" |
"F13" |
kVK_F16 (0x6A) |
"F16" |
"F16" |
kVK_F14 (0x6B) |
"F14" |
"F14" |
kVK_F10 (0x6D) |
"F10" |
"F10" |
上下文菜单键 (0x6E ) |
"ContextMenu" |
"ContextMenu" |
kVK_F12 (0x6F) |
"F12" |
"F12" |
kVK_F15 (0x71) |
"F15" |
"F15" |
kVK_Help (0x72) |
"Help" (⚠️ Chromium 上有所不同) |
"Insert" (⚠️ Firefox 上有所不同) |
kVK_Home (0x73) |
"Home" |
"Home" |
kVK_PageUp (0x74) |
"PageUp" |
"PageUp" |
kVK_ForwardDelete (0x75) |
"Delete" |
"Delete" |
kVK_F4 (0x76) |
"F4" |
"F4" |
kVK_End (0x77) |
"End" |
"End" |
kVK_F2 (0x78) |
"F2" |
"F2" |
kVK_PageDown (0x79) |
"PageDown" |
"PageDown" |
kVK_F1 (0x7A) |
"F1" |
"F1" |
kVK_LeftArrow (0x7B) |
"向左箭头" |
"向左箭头" |
kVK_RightArrow (0x7C) |
"向右箭头" |
"向右箭头" |
kVK_DownArrow (0x7D) |
"向下箭头" |
"向下箭头" |
kVK_UpArrow (0x7E) |
"向上箭头" |
"向上箭头" |
Linux (X11) 上的代码值
请注意,X 拥有过多的按键,其中一些无法使用普通键盘进行测试。因此,下表是从源代码中创建的,该源代码将扫描码映射到代码值。
在单元格中,“(❌ 缺失)” 表示此代码值在此浏览器中无法检测到。
扫描码 (硬件键码) | Firefox | Chromium |
---|---|---|
0x0009 |
"Escape" |
"Escape" |
0x000A |
"Digit1" |
"Digit1" |
0x000B |
"Digit2" |
"Digit2" |
0x000C |
"Digit3" |
"Digit3" |
0x000D |
"Digit4" |
"Digit4" |
0x000E |
"Digit5" |
"Digit5" |
0x000F |
"Digit6" |
"Digit6" |
0x0010 |
"Digit7" |
"Digit7" |
0x0011 |
"Digit8" |
"Digit8" |
0x0012 |
"Digit9" |
"Digit9" |
0x0013 |
"Digit0" |
"Digit0" |
0x0014 |
"Minus" |
"Minus" |
0x0015 |
"Equal" |
"Equal" |
0x0016 |
"Backspace" |
"Backspace" |
0x0017 |
"Tab" |
"Tab" |
0x0018 |
"KeyQ" |
"KeyQ" |
0x0019 |
"KeyW" |
"KeyW" |
0x001A |
"KeyE" |
"KeyE" |
0x001B |
"KeyR" |
"KeyR" |
0x001C |
"KeyT" |
"KeyT" |
0x001D |
"KeyY" |
"KeyY" |
0x001E |
"KeyU" |
"KeyU" |
0x001F |
"KeyI" |
"KeyI" |
0x0020 |
"KeyO" |
"KeyO" |
0x0021 |
"KeyP" |
"KeyP" |
0x0022 |
"BracketLeft" |
"BracketLeft" |
0x0023 |
"BracketRight" |
"BracketRight" |
0x0024 |
"Enter" |
"Enter" |
0x0025 |
"ControlLeft" |
"ControlLeft" |
0x0026 |
"KeyA" |
"KeyA" |
0x0027 |
"KeyS" |
"KeyS" |
0x0028 |
"KeyD" |
"KeyD" |
0x0029 |
"KeyF" |
"KeyF" |
0x002A |
"KeyG" |
"KeyG" |
0x002B |
"KeyH" |
"KeyH" |
0x002C |
"KeyJ" |
"KeyJ" |
0x002D |
"KeyK" |
"KeyK" |
0x002E |
"KeyL" |
"KeyL" |
0x002F |
"Semicolon" |
"Semicolon" |
0x0030 |
"Quote" |
"Quote" |
0x0031 |
"Backquote" |
"Backquote" |
0x0032 |
"ShiftLeft" |
"ShiftLeft" |
0x0033 |
"Backslash" |
"Backslash" |
0x0034 |
"KeyZ" |
"KeyZ" |
0x0035 |
"KeyX" |
"KeyX" |
0x0036 |
"KeyC" |
"KeyC" |
0x0037 |
"KeyV" |
"KeyV" |
0x0038 |
"KeyB" |
"KeyB" |
0x0039 |
"KeyN" |
"KeyN" |
0x003A |
"KeyM" |
"KeyM" |
0x003B |
"Comma" |
"Comma" |
0x003C |
"Period" |
"Period" |
0x003D |
"Slash" |
"Slash" |
0x003E |
"ShiftRight" |
"ShiftRight" |
0x003F |
"NumpadMultiply" |
"NumpadMultiply" |
0x0040 |
"AltLeft" |
"AltLeft" |
0x0041 |
"Space" |
"Space" |
0x0042 |
"CapsLock" |
"CapsLock" |
0x0043 |
"F1" |
"F1" |
0x0044 |
"F2" |
"F2" |
0x0045 |
"F3" |
"F3" |
0x0046 |
"F4" |
"F4" |
0x0047 |
"F5" |
"F5" |
0x0048 |
"F6" |
"F6" |
0x0049 |
"F7" |
"F7" |
0x004A |
"F8" |
"F8" |
0x004B |
"F9" |
"F9" |
0x004C |
"F10" |
"F10" |
0x004D |
"NumLock"
|
"NumLock"
|
0x004E |
"ScrollLock" |
"ScrollLock" |
0x004F |
"Numpad7" |
"Numpad7" |
0x0050 |
"Numpad8" |
"Numpad8" |
0x0051 |
"Numpad9" |
"Numpad9" |
0x0052 |
"NumpadSubtract" |
"NumpadSubtract" |
0x0053 |
"Numpad4" |
"Numpad4" |
0x0054 |
"Numpad5" |
"Numpad5" |
0x0055 |
"Numpad6" |
"Numpad6" |
0x0056 |
"NumpadAdd" |
"NumpadAdd" |
0x0057 |
"Numpad1" |
"Numpad1" |
0x0058 |
"Numpad2" |
"Numpad2" |
0x0059 |
"Numpad3" |
"Numpad3" |
0x005A |
"Numpad0" |
"Numpad0" |
0x005B |
"NumpadDecimal" |
"NumpadDecimal" |
0x005C |
"Unidentified" |
"" |
0x005D |
"Unidentified" (❌ 缺失) |
"Lang5" (Chromium 48 之前版本为 "" ) (⚠️ Firefox 上有所不同) |
0x005E |
"IntlBackslash" |
"IntlBackslash" |
0x005F |
"F11" |
"F11" |
0x0060 |
"F12" |
"F12" |
0x0061 |
"IntlRo" |
"IntlRo" |
0x0062 |
"Unidentified" (❌ 缺失) |
"Lang3" (⚠️ Firefox 上有所不同) |
0x0063 |
"Unidentified" (❌ 缺失) |
"Lang4" (⚠️ Firefox 上有所不同) |
0x0064 |
"Convert" |
"Convert" |
0x0065 |
"KanaMode" |
"KanaMode" |
0x0066 |
"NonConvert" |
"NonConvert" |
0x0067 |
"Unidentified" |
"" |
0x0068 |
"NumpadEnter" |
"NumpadEnter" |
0x0069 |
"ControlRight" |
"ControlRight" |
0x006A |
"NumpadDivide" |
"NumpadDivide" |
0x006B |
"PrintScreen" |
"PrintScreen" |
0x006C |
"AltRight" |
"AltRight" |
0x006D |
"Unidentified" |
"" |
0x006E |
"Home" |
"Home" |
0x006F |
"向上箭头" |
"向上箭头" |
0x0070 |
"PageUp" |
"PageUp" |
0x0071 |
"向左箭头" |
"向左箭头" |
0x0072 |
"向右箭头" |
"向右箭头" |
0x0073 |
"End" |
"End" |
0x0074 |
"向下箭头" |
"向下箭头" |
0x0075 |
"PageDown" |
"PageDown" |
0x0076 |
"Insert" |
"Insert" |
0x0077 |
"Delete" |
"Delete" |
0x0078 |
"Unidentified" |
"" |
0x0079 |
"VolumeMute" (⚠️ Chromium 上有所不同) |
"AudioVolumeMute" (Chromium 52 之前版本为 "VolumeMute" ) (⚠️ Firefox 上有所不同) |
0x007A |
"VolumeDown" (⚠️ Chromium 上有所不同) |
"AudioVolumeDown" (Chromium 52 之前版本为 "VolumeDown" ) (⚠️ Firefox 上有所不同) |
0x007B |
"VolumeUp" (⚠️ Chromium 上有所不同) |
"AudioVolumeUp" (Chromium 52 之前版本为 "VolumeUp" ) (⚠️ Firefox 上有所不同) |
0x007C |
"Unidentified" (❌ 缺失) |
"Power" (⚠️ Firefox 上有所不同) |
0x007D |
"NumpadEqual" |
"NumpadEqual" |
0x007E |
"Unidentified" |
"" |
0x007F |
"Pause" |
"Pause" |
0x0080 |
"Unidentified" |
"" |
0x0081 |
"NumpadComma" |
"NumpadComma" |
0x0082 |
"Lang1" |
"Lang1" |
0x0083 |
"Lang2" |
"Lang2" |
0x0084 |
"IntlYen" |
"IntlYen" |
0x0085 |
"MetaLeft" (Firefox 118 之前版本为 "OSLeft" ) |
"MetaLeft" (Chromium 52 之前版本为 "OSLeft" ) |
0x0086 |
"MetaRight" (Firefox 118 之前版本为 "OSRight" ) |
"MetaRight" (Chromium 52 之前版本为 "OSRight" ) |
0x0087 |
"ContextMenu" |
"ContextMenu" |
0x0088 |
"浏览器停止" |
"BrowserStop" (Chromium 48 之前版本为 "Abort" ) |
0x0089 |
"再次" |
"再次" |
0x008A |
"Props" (⚠️ Chromium 上有所不同) |
"" (❌ 缺失) |
0x008B |
"撤销" |
"撤销" |
0x008C |
"选择" |
"Select" (Chromium 48 之前版本为 "" ) |
0x008D |
"复制" |
"复制" |
0x008E |
"打开" |
"Open" (Chromium 48 之前版本为 "" ) |
0x008F |
"粘贴" |
"粘贴" |
0x0090 |
"查找" |
"查找" |
0x0091 |
"剪切" |
"剪切" |
0x0092 |
"帮助" |
"帮助" |
0x0093 |
"Unidentified" |
"" |
0x0094 |
"LaunchApp2" |
"LaunchApp2" |
0x0095 |
"Unidentified" |
"" |
0x0096 |
"Unidentified" (❌ 缺失) |
"Sleep" (⚠️ Firefox 上有所不同) |
0x0097 |
"唤醒" |
"唤醒" |
0x0098 |
"启动应用1" |
"LaunchApp1" (Chromium 48 之前版本为 "" ) |
0x0099 ~ 0x00A2 |
"Unidentified" |
"" |
0x00A3 |
"启动邮件" |
"LaunchMail" (Chromium 51 之前版本为 "" ) |
0x00A4 |
"浏览器收藏夹" |
"浏览器收藏夹" |
0x00A5 |
"Unidentified" |
"" |
0x00A6 |
"浏览器后退" |
"浏览器后退" |
0x00A7 |
"浏览器前进" |
"浏览器前进" |
0x00A8 |
"Unidentified" |
"" |
0x00A9 |
"弹出" |
"Eject" (Chromium 48 之前版本为 "" ) |
0x00AA |
"Unidentified" |
"" |
0x00AB |
"MediaTrackNext" |
"MediaTrackNext" (Chromium 48 之前版本为 "" ) |
0x00AC |
"MediaPlayPause" |
"MediaPlayPause" (Chromium 48 之前版本为 "" ) |
0x00AD |
"MediaTrackPrevious" |
"MediaTrackPrevious" (Chromium 48 之前版本为 "" ) |
0x00AE |
"MediaStop" |
"MediaStop" (Chromium 48 之前版本为 "" ) |
0x00AF ~ 0x00B2 |
"Unidentified" |
"" |
0x00B3 |
"媒体选择" |
"MediaSelect" (Chromium 48 之前版本为 "" ) |
0x00B4 |
"BrowserHome" |
"BrowserHome" (Chromium 48 之前版本为 "" ) |
0x00B5 |
"浏览器刷新" |
"浏览器刷新" |
0x00B6 ~ 0x00BA |
"Unidentified" |
"" |
0x00BB |
"Unidentified" (❌ 缺失) |
"NumpadParenLeft" (⚠️ Firefox 上有所不同) |
0x00BC |
"Unidentified" (❌ 缺失) |
"NumpadParenRight" (⚠️ Firefox 上有所不同) |
0x00BD , 0x00BE |
"Unidentified" |
"" |
0x00BF |
"F13" |
"F13" |
0x00C0 |
"F14" |
"F14" |
0x00C1 |
"F15" |
"F15" |
0x00C2 |
"F16" |
"F16" |
0x00C3 |
"F17" |
"F17" |
0x00C4 |
"F18" |
"F18" |
0x00C5 |
"F19" |
"F19" |
0x00C6 |
"F20" |
"F20" |
0x00C7 |
"F21" |
"F21" |
0x00C8 |
"F22" |
"F22" |
0x00C9 |
"F23" |
"F23" |
0x00CA |
"F24" |
"F24" |
0x00CB ~ 0x00E0 |
|
"" |
0x00E1 |
"BrowserSearch" (⚠️ Chromium 上有所不同) |
"BrowserSearch" (Chromium 48 之前版本为 "BrightnessUp" ) |
Firefox for Android 上的代码值
扫描码 | Firefox |
---|---|
0x0001 |
"Escape" |
0x0002 |
"Digit1" |
0x0003 |
"Digit2" |
0x0004 |
"Digit3" |
0x0005 |
"Digit4" |
0x0006 |
"Digit5" |
0x0007 |
"Digit6" |
0x0008 |
"Digit7" |
0x0009 |
"Digit8" |
0x000A |
"Digit9" |
0x000B |
"Digit0" |
0x000C |
"Minus" |
0x000D |
"Equal" |
0x000E |
"Backspace" |
0x000F |
"Tab" |
0x0010 |
"KeyQ" |
0x0011 |
"KeyW" |
0x0012 |
"KeyE" |
0x0013 |
"KeyR" |
0x0014 |
"KeyT" |
0x0015 |
"KeyY" |
0x0016 |
"KeyU" |
0x0017 |
"KeyI" |
0x0018 |
"KeyO" |
0x0019 |
"KeyP" |
0x001A |
"BracketLeft" |
0x001B |
"BracketRight" |
0x001C |
"Enter" |
0x001D |
"ControlLeft" |
0x001E |
"KeyA" |
0x001F |
"KeyS" |
0x0020 |
"KeyD" |
0x0021 |
"KeyF" |
0x0022 |
"KeyG" |
0x0023 |
"KeyH" |
0x0024 |
"KeyJ" |
0x0025 |
"KeyK" |
0x0026 |
"KeyL" |
0x0027 |
"Semicolon" |
0x0028 |
"Quote" |
0x0029 |
"Backquote" |
0x002A |
"ShiftLeft" |
0x002B |
"Backslash" |
0x002C |
"KeyZ" |
0x002D |
"KeyX" |
0x002E |
"KeyC" |
0x002F |
"KeyV" |
0x0030 |
"KeyB" |
0x0031 |
"KeyN" |
0x0032 |
"KeyM" |
0x0033 |
"Comma" |
0x0034 |
"Period" |
0x0035 |
"Slash" |
0x0036 |
"ShiftRight" |
0x0037 |
"NumpadMultiply" |
0x0038 |
"AltLeft" |
0x0039 |
"Space" |
0x003A |
"CapsLock" |
0x003B |
"F1" |
0x003C |
"F2" |
0x003D |
"F3" |
0x003E |
"F4" |
0x003F |
"F5" |
0x0040 |
"F6" |
0x0041 |
"F7" |
0x0042 |
"F8" |
0x0043 |
"F9" |
0x0044 |
"F10" |
0x0045 |
"NumLock"
|
0x0046 |
"ScrollLock" |
0x0047 |
"Numpad7" |
0x0048 |
"Numpad8" |
0x0049 |
"Numpad9" |
0x004A |
"NumpadSubtract" |
0x004B |
"Numpad4" |
0x004C |
"Numpad5" |
0x004D |
"Numpad6" |
0x004E |
"NumpadAdd" |
0x004F |
"Numpad1" |
0x0050 |
"Numpad2" |
0x0051 |
"Numpad3" |
0x0052 |
"Numpad0" |
0x0053 |
"NumpadDecimal" |
0x0054 , 0x0055 |
|
0x0056 |
"IntlBackslash" |
0x0057 |
"F11" |
0x0058 |
"F12" |
0x0059 |
"IntlRo" |
0x005A , 0x005B |
|
0x005C |
"Convert" |
0x005D |
"KanaMode" |
0x005E |
"NonConvert" |
0x005F |
|
0x0060 |
"NumpadEnter" |
0x0061 |
"ControlRight" |
0x0062 |
"NumpadDivide" |
0x0063 |
"PrintScreen" |
0x0064 |
"AltRight" |
0x0065 |
|
0x0066 |
"Home" |
0x0067 |
"向上箭头" |
0x0068 |
"PageUp" |
0x0069 |
"向左箭头" |
0x006A |
"向右箭头" |
0x006B |
"End" |
0x006C |
"向下箭头" |
0x006D |
"PageDown" |
0x006E |
"Insert" |
0x006F |
"Delete" |
0x0070 |
|
0x0071 |
|
0x0072 |
|
0x0073 |
|
0x0074 |
"电源" |
0x0075 |
"NumpadEqual" |
0x0076 |
|
0x0077 |
"Pause" |
0x0078 |
|
0x0079 |
"NumpadComma" |
0x007A |
"Lang1" |
0x007B |
"Lang2" |
0x007C |
"IntlYen" |
0x007D |
|
0x007E |
|
0x007F |
"ContextMenu" |
0x0080 |
"浏览器停止" |
0x0081 |
"再次" |
0x0082 |
"属性" |
0x0083 |
"撤销" |
0x0084 |
"选择" |
0x0085 |
"复制" |
0x0086 |
"打开" |
0x0087 |
"粘贴" |
0x0088 |
"查找" |
0x0089 |
"剪切" |
0x008A |
"帮助" |
0x008B ~ 0x008D |
|
0x008E |
"睡眠" |
0x008F |
"唤醒" |
0x0090 |
"启动应用1" |
0x0091 ~ 0x009B |
|
0x009C |
"浏览器收藏夹" |
0x009D |
|
0x009E |
"浏览器后退" |
0x009F |
"浏览器前进" |
0x00A0 |
|
0x00A1 |
"弹出" |
0x00A2 |
|
0x00A3 |
"MediaTrackNext" |
0x00A4 |
"MediaPlayPause" |
0x00A5 |
"MediaTrackPrevious" |
0x00A6 |
"MediaStop" |
0x00A7 ~ 0x00AC |
|
0x00AD |
"浏览器刷新" |
0x00AE ~ 0x00B6 |
"Unidentified" |
0x00B7 |
"F13" |
0x00B8 |
"F14" |
0x00B9 |
"F15" |
0x00BA |
"F16" |
0x00BB |
"F17" |
0x00BC |
"F18" |
0x00BD |
"F19" |
0x00BE |
"F20" |
0x00BF |
"F21" |
0x00C0 |
"F22" |
0x00C1 |
"F23" |
0x00C2 |
"F24" |
0x00C3 ~ 0x00D8 |
|
0x00D9 |
"浏览器搜索" |
0x00DA ~ 0x01CF |
|
0x01D0 |
"Fn" |