--- title: KeyboardEvent.keyCode slug: Web/API/KeyboardEvent/keyCode translation_of: Web/API/KeyboardEvent/keyCode ---

{{APIRef("DOM Events")}}{{deprecated_header()}}

这个只读的属性 KeyboardEvent.keyCode 代表着一个唯一标识的所按下的键的未修改值,它依据于一个系统和实现相关的数字代码。这通常是与密钥对应的二进制的ASCII ({{RFC(20)}})或Windows 1252 码。如果这个键不能被标志,这个值为0。

你应该尽量避免使用它;它已经被弃用了一段时间。相反的,如果它在你的浏览器中被实现了的话,你应该使用{{domxref("KeyboardEvent.code")}}。 不幸的是,有一些浏览器还是没有实现它,所以你在使用之前必须要小心,确认你所使用的那个被所有目标浏览器所支持。

在处理keydown和keyup事件时,Web开发人员不应使用可打印字符的keycode属性。如上所述,keycode属性对可打印字符不有用,尤其是那些按下shift或alt键的输入。在实现快捷键处理程序时,事件(“keypress”)事件通常更好(至少当gecko是正在使用的运行时)。详情请参见Gecko按键事件.

Example

window.addEventListener("keydown", function (event) {
  if (event.defaultPrevented) {
    return; // 如果已取消默认操作,则不应执行任何操作
  }

  var handled = false;
  if (event.key !== undefined) {
    // 使用KeyboardEvent.key处理事件,并将handled设置为true。
  } else if (event.keyCode !== undefined) {
    //使用KeyboardEvent.keyCode处理事件并将handled设置为true。
  }

  if (handled) {
    // 如果事件已处理,则禁止“双重操作”
    event.preventDefault();
  }
}, true);

规范

规范 状态 Comment评论
{{SpecName('DOM3 Events','#widl-KeyboardEvent-keyCode','KeyboardEvent.keyCode')}} {{Spec2('DOM3 Events')}} 初始定义;指定为已弃用

浏览器兼容性

{{ CompatibilityTable() }}

特征 谷歌 Edge Firefox (Gecko) Internet Explorer Opera Safari
基础支持 26 (probably earlier) {{CompatVersionUnknown}} 3.0 (possibly earlier) 6 11.6 (probably earlier) 5 (probably earlier)
特征 Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
基础支持 {{ CompatUnknown() }} {{ CompatUnknown() }} {{CompatVersionUnknown}} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

5.1

{{Compat("api.KeyboardEvent.keyCode")}}

键码值

标准位置的可打印键

在标准位置按下或释放可打印键导致的按键事件值在浏览器之间不兼容。
IE只将本机虚拟密钥代码值公开为keyboardvent.keycode。
Google Chrome、Chromium和Safari必须根据输入字符确定值。如果输入字符可以用US键盘布局输入,则使用US键盘布局上的keycode值。
从gecko 15 geckore lease(“15.0”)开始,gecko从一个可由键输入的ASCII字符(即使具有移位修饰符或支持ASCII的键盘布局)决定键码值。有关详细信息,请参见以下规则:

  1. 如果系统是Windows,并且按下键的本机键代码指示键是A-Z或0-9,请使用keycode。
  2. 如果系统是Mac,并且按下键的本机键码指示键为0-9,则使用keycode。
  3. 如果按下键输入一个ASCII字母或数字,没有修改键,请使用keycode。
  4. 如果按下键输入带SHIFT键的ASCII字母或数字,请使用keycode。
  5. 如果按下键输入另一个没有修改键的ASCII字符,请使用keycode。
  6. 如果按下键输入另一个带SHIFT键的ASCII字符,请使用keycode。
  7. 否则,即按下键输入一个Unicode字符:

从 Firefox 60 {{geckoRelease("60.0")}}开始, Gecko 会尽可能的根据以下规则额设置标点符号的 keyCode 值(当满足上述7.1或者7.2的时候):

这些附加规则的目的是为了使键盘布局映射unicode字符映射到美国键盘标点符号的用户可以使用只支持ASCII的键盘或者美国键盘布局的Firefox的web应用。否则,新映射的 keyCode 值可能会和其他按键冲突。例如,如果当前键盘布局是俄语,"Period" 键 和 "Slash" 键的 keyCode 都会是 190KeyEvent.DOM_VK_PERIOD)。如果你需要区分这些按键但是你自己又不想支持时间上所有的键盘布局,你可能应该使用 {{domxref("KeyboardEvent.code")}}。

  1. 如果运行macOS或者Linux:
    1. 如果你当前的键盘布局不支持ASCII并且候选支持ASCII键盘布局可用。
      1. 如果候选支持ASCII的键盘布局仅通过未修改的键产生ASCII字符,请对该字符使用keyCode。
      2. 如果候选支持ASCII的键盘布局产生带有Shift键修饰符的ASCII字符,请对该字符使用keyCode
      3. 否则,在美国键盘布局激活时,使用使用keyCode表示由按键产生的ASCII字符。
    2. 否则,在美国键盘布局激活时,使用使用keyCode表示由按键产生的ASCII字符。
  2. 如果运行Windows:
    1. 当美国键盘布局激活时,使用映射到Windows的相同虚拟键代码的按键产生的ASCII字符的keyCode值。

由标准位置的可打印键引起的每个浏览器的keydown事件的keycode值

{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek
{{domxref("KeyboardEvent.code")}} US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
"Digit1" 0x31 (49) 0x31 (49) 0x31 (49) 0x31 (49) 0x31 (49) 0x31 (49) 0x31 (49) 0x31 (49)
"Digit2" 0x32 (50) 0x32 (50) 0x32 (50) 0x32 (50) 0x32 (50) 0x32 (50) 0x32 (50) 0x32 (50)
"Digit3" 0x33 (51) 0x33 (51) 0x33 (51) 0x33 (51) 0x33 (51) 0x33 (51) 0x33 (51) 0x33 (51)
"Digit4" 0x34 (52) 0x34 (52) 0x34 (52) 0x34 (52) 0x34 (52) 0x34 (52) 0x34 (52) 0x34 (52)
"Digit5" 0x35 (53) 0x35 (53) 0x35 (53) 0x35 (53) 0x35 (53) 0x35 (53) 0x35 (53) 0x35 (53)
"Digit6" 0x36 (54) 0x36 (54) 0x36 (54) 0x36 (54) 0x36 (54) 0x36 (54) 0x36 (54) 0x36 (54)
"Digit7" 0x37 (55) 0x37 (55) 0x37 (55) 0x37 (55) 0x37 (55) 0x37 (55) 0x37 (55) 0x37 (55)
"Digit8" 0x38 (56) 0x38 (56) 0x38 (56) 0x38 (56) 0x38 (56) 0x38 (56) 0x38 (56) 0x38 (56)
"Digit9" 0x39 (57) 0x39 (57) 0x39 (57) 0x39 (57) 0x39 (57) 0x39 (57) 0x39 (57) 0x39 (57)
"Digit0" 0x30 (48) 0x30 (48) 0x30 (48) 0x30 (48) 0x30 (48) 0x30 (48) 0x30 (48) 0x30 (48)
"KeyA" 0x41 (65) 0x41 (65) 0x41 (65) 0x41 (65) 0x41 (65) 0x41 (65) 0x41 (65) 0x41 (65)
"KeyB" 0x42 (66) 0x42 (66) 0x42 (66) 0x42 (66) 0x42 (66) 0x42 (66) 0x42 (66) 0x42 (66)
"KeyC" 0x43 (67) 0x43 (67) 0x43 (67) 0x43 (67) 0x43 (67) 0x43 (67) 0x43 (67) 0x43 (67)
"KeyD" 0x44 (68) 0x44 (68) 0x44 (68) 0x44 (68) 0x44 (68) 0x44 (68) 0x44 (68) 0x44 (68)
"KeyE" 0x45 (69) 0x45 (69) 0x45 (69) 0x45 (69) 0x45 (69) 0x45 (69) 0x45 (69) 0x45 (69)
"KeyF" 0x46 (70) 0x46 (70) 0x46 (70) 0x46 (70) 0x46 (70) 0x46 (70) 0x46 (70) 0x46 (70)
"KeyG" 0x47 (71) 0x47 (71) 0x47 (71) 0x47 (71) 0x47 (71) 0x47 (71) 0x47 (71) 0x47 (71)
"KeyH" 0x48 (72) 0x48 (72) 0x48 (72) 0x48 (72) 0x48 (72) 0x48 (72) 0x48 (72) 0x48 (72)
"KeyI" 0x49 (73) 0x49 (73) 0x49 (73) 0x49 (73) 0x49 (73) 0x49 (73) 0x49 (73) 0x49 (73)
"KeyJ" 0x4A (74) 0x4A (74) 0x4A (74) 0x4A (74) 0x4A (74) 0x4A (74) 0x4A (74) 0x4A (74)
"KeyK" 0x4B (75) 0x4B (75) 0x4B (75) 0x4B (75) 0x4B (75) 0x4B (75) 0x4B (75) 0x4B (75)
"KeyL" 0x4C (76) 0x4C (76) 0x4C (76) 0x4C (76) 0x4C (76) 0x4C (76) 0x4C (76) 0x4C (76)
"KeyM" 0x4D (77) 0x4D (77) 0x4D (77) 0x4D (77) 0x4D (77) 0x4D (77) 0x4D (77) 0x4D (77)
"KeyN" 0x4E (78) 0x4E (78) 0x4E (78) 0x4E (78) 0x4E (78) 0x4E (78) 0x4E (78) 0x4E (78)
"KeyO" 0x4F (79) 0x4F (79) 0x4F (79) 0x4F (79) 0x4F (79) 0x4F (79) 0x4F (79) 0x4F (79)
"KeyP" 0x50 (80) 0x50 (80) 0x50 (80) 0x50 (80) 0x50 (80) 0x50 (80) 0x50 (80) 0x50 (80)
"KeyQ" 0x51 (81) 0x51 (81) 0x51 (81) 0x51 (81) 0xBA (186) 0x51 (81) 0x51 (81) 0xBA (186) 0x51 (81) 0x51 (81) 0xBA (186) 0x51 (81) 0x51 (81) 0x51 (81) 0xBA (186) 0x51 (81)
"KeyR" 0x52 (82) 0x52 (82) 0x52 (82) 0x52 (82) 0x52 (82) 0x52 (82) 0x52 (82) 0x52 (82)
"KeyS" 0x53 (83) 0x53 (83) 0x53 (83) 0x53 (83) 0x53 (83) 0x53 (83) 0x53 (83) 0x53 (83)
"KeyT" 0x54 (84) 0x54 (84) 0x54 (84) 0x54 (84) 0x54 (84) 0x54 (84) 0x54 (84) 0x54 (84)
"KeyU" 0x55 (85) 0x55 (85) 0x55 (85) 0x55 (85) 0x55 (85) 0x55 (85) 0x55 (85) 0x55 (85)
"KeyV" 0x56 (86) 0x56 (86) 0x56 (86) 0x56 (86) 0x56 (86) 0x56 (86) 0x56 (86) 0x56 (86)
"KeyW" 0x57 (87) 0x57 (87) 0x57 (87) 0x57 (87) 0x57 (87) 0x57 (87) 0x57 (87) 0x57 (87)
"KeyX" 0x58 (88) 0x58 (88) 0x58 (88) 0x58 (88) 0x58 (88) 0x58 (88) 0x58 (88) 0x58 (88)
"KeyY" 0x59 (89) 0x59 (89) 0x59 (89) 0x59 (89) 0x59 (89) 0x59 (89) 0x59 (89) 0x59 (89)
"KeyZ" 0x5A (90) 0x5A (90) 0x5A (90) 0x5A (90) 0x5A (90) 0x5A (90) 0x5A (90) 0x5A (90)

由标准位置的可打印键(US布局中的标点符号)引起的每个浏览器的keydown事件的keycode值:

{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows (10.9) Mac (10.9) Linux (Ubuntu 14.04)
US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek
{{domxref("KeyboardEvent.code")}} US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek US Japanese Greek
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
"Comma" 0xBC (188) 0xBC (188) 0xBC (188) 0xBC (188) 0xBC (188) 0xBC (188) 0xBC (188) 0xBC (188)
"Comma" with Shift
"Period" 0xBE (190) 0xBE (190) 0xBE (190) 0xBE (190) 0xBE (190) 0xBE (190) 0xBE (190) 0xBE (190)
"Period" with Shift
"Semicolon" 0xBA (186) 0xBB (187) 0xBA (186) 0xBA (186) 0xBB (187) 0xBA (186) 0xBA (186) 0xBA (186) *1 0xE5 (229) *2 0xBA (186) 0xBA (186) 0xE5 (229) *3 0xBA (186) 0xBA (186) *1 0xE5 (229) *2 0x3B (59) 0x3B (59) 0x00 (0) 0x3B (59) 0x3B (59) *1 0x00 (0) 0x3B (59) 0x3B (59) 0x00 (0)
"Semicolon" with Shift 0xBB (187) *1 0xBB (187) 0xBB (187) *1
"Quote" 0xDE (222) 0xBA (186) 0xDE (222) 0xDE (222) 0xBA (186) 0xDE (222) 0xDE (222) 0xBA (186) *1 0xDE (222) 0xDE (222) 0xBA (186) 0xDE (222) 0xDE (222) 0xBA (186)  *1 0xDE (222) 0xDE (222) 0x3A (58) 0xDE (222) 0xDE (222) 0x3A (58) *1 0xDE (222) 0xDE (222) 0x3A (58) 0xDE (222)
"Quote" with Shift 0xDE (222) *1 0x38 (56) 0xDE (222) *1
"BracketLeft" 0xDB (219) 0xC0(192) 0xDB (219) 0xDB (219) 0xC0(192) 0xDB (219) 0xDB (219) 0xDB (219) *1 0xDB (219) 0xDB (219) 0x32 (50) 0xDB (219) 0xDB (219) 0xDB (219) *1 0xDB (219) 0xDB (219) 0x40 (64) 0xDB (219) 0xDB (219) 0x40 (64) *1 0xDB (219) 0xDB (219) 0x40 (64) 0xDB (219)
"BracketLeft" with Shift 0xC0 (192) *1 0xC0 (192) 0xC0 (192) *1
"BracketRight" 0xDD (221) 0xDB (219) 0xDD (221) 0xDD (221) 0xDB (219) 0xDD (221) 0xDD (221) 0xDB (219) *1 0xDD (221) 0xDD (221) 0xDB (219) 0xDD (221) 0xDD (221) 0xDB (219) *1 0xDD (221) 0xDD (221) 0xDB (219) 0xDD (221) 0xDD (221) 0xDB (219) *1 0xDD (221) 0xDD (221) 0xDB (219) 0xDD (221)
"BracketRight" with Shift
"Backquote" 0xC0 (192) N/A 0xC0 (192) 0xC0 (192) N/A 0xC0 (192) 0xC0 (192) 0xC0 (192) 0xF4 (244) 0xC0 (192) 0xC0 (192) 0xC0 (192) N/A 0xC0 (192) 0xC0 (192) 0xC0 (192) 0x00 (0) 0xC0 (192)
"Backquote" with Shift
"Backslash" 0xDC (220) 0xDD (221) 0xDC (220) 0xDC (220) 0xDD (221) 0xDC (220) 0xDC (220) 0xDC (220) 0xDD (221) 0xDC (220) 0xDC (220) 0xDC (220) 0xDD (221) 0xDC (220) 0xDC (220) 0xDC (220) 0xDD (221) 0xDC (220)
"Backslash" with Shift
"Minus" 0xBD (189) 0xBD (189) 0xBD (189) 0xBD (189) *1 0xBD (189) 0xBD (189) 0xBD (189) 0xBD (189) 0xBD (189) 0xBD (189) *1 0xBD (189) 0xAD (173) 0xAD (173) 0xAD (173) *1 0xAD (173) 0xAD (173)
"Minus" with Shift 0xBB (187) *1 0xBB (187) 0xBD (189) 0xBB (187) *1 0xBD (189)
"Equal" 0xBB (187) 0xDE (222) 0xBB (187) 0xBB (187) 0xDE (222) 0xBB (187) 0xBB (187) 0xBB (187) *1 0xBB (187) 0xBB (187) 0x36 (54) 0xBB (187) 0xBB (187) 0xBB (187) *1 0xBB (187) 0x3D (61) 0xA0 (160) 0x3D (61) 0x3D (61) 0xA0 (160) *1 0x3D (61) 0x3D (61) 0xA0 (160) 0x3D (61)
"Equal" with Shift 0xC0 (192) *1 0xC0 (192) 0xBB (187) 0xC0 (192) *1 0xBB (187)
"IntlRo" 0xC1 (193) 0xE2 (226) 0xC1 (193) 0xC1 (193) 0xE2 (226) 0xC1 (193) 0xBD (189) 0xBD (189) 0x00 (0) *4 0xDC (220)
 
*4 0xBD (189) 0xBD (189) 0xE5 (229) *5 0x00 (0) 0xDC (220) 0x00 (0) 0xA7 (167) 0xA7 (167) 0x00 (0) 0x00 (0) 0xDC (220) 0x00 (0)
"IntlRo" with Shift
"IntlYen" 0xFF (255) 0xDC (220) 0xFF (255) 0xFF (255) 0xDC (220) 0xFF (255) 0x00 (0) 0x00 (0) 0x00 (0) *4 0xDC (220) *4 0x00 (0) 0x00 (0) 0xE5 (229) *5 0x00 (0) 0xDC (220) 0x00 (0) 0xDC (220) 0xDC (220) 0x00 (0) 0x00 (0) 0xDC (220) 0x00 (0)
"IntlYen" with Shift 0xDC (220) 0xDC (220) 0xBD (189) 0xDC (220) 0xDC (220)

*1该值是从JIS键盘输入的。使用ANSI键盘时,键代码值和输入字符是从美国键盘布局中选择的。
*2按键是一个死键。keyup事件的值是0xba(186)。
*3按键是一个死键。keyup事件的值为0x10(16)。
*4没有触发任何按键事件。
*5该键在希腊键盘布局中不可用(不输入任何字符)。keyup事件的值为0x00(0)。

不可打印键(功能键)

由修改键引起的每个浏览器的keydown事件的keycode值:
{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
{{domxref("KeyboardEvent.code")}} Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
"AltLeft" 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18)
"AltRight" 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18) 0x12 (18)
"AltRight" when it's "AltGraph" key *1 *1 N/A 0xE1 (225) N/A *1 N/A 0xE1 (225)
"CapsLock" 0x14 (20) *2 0x14 (20) *2 0x14 (20) 0x14 (20) 0x14 (20) 0x14 (20) *2 0x14 (20) 0x14 (20) *3
"ControlLeft" 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17)
"ControlRight" 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17) 0x11 (17)
"OSLeft" 0x5B (91) 0x5B (91) 0x5B (91) 0x5B (91) 0x5B (91) 0x5B (91) 0xE0 (224) 0x5B (91)
"OSRight" 0x5C (92) 0x5C (92) 0x5D (93) 0x5C (92) 0x5D (93) 0x5B (91) 0xE0 (224) 0x5B (91)
"ShiftLeft" 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16)
"ShiftRight" 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16) 0x10 (16)

*1在Windows上,“altgraph”键导致“controlLeft”键事件和“altRight”键事件。
*2当日语键盘布局处于活动状态时,“capslock”键没有 Shift 会导致0xf0(240)。该键作为“Alphanumeric”键工作,其标签为“英数”。
*3当日语键盘布局处于活动状态时,“capslock”键没有 Shift 会导致0x00(0)。该键作为“Alphanumeric”键工作,其标签为“英数”。

由不可打印的键引起的每个浏览器的keydown事件的keycode值:

{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
{{domxref("KeyboardEvent.code")}} Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
"ContextMenu" 0x5D (93) 0x5D (93) 0x00 (0) *1 0x5D (93) 0x00 (0) *1 0x5D (93) 0x5D (93) 0x5D (93)
"Enter" 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13)
"Space" 0x20 (32) 0x20 (32) 0x20 (32) 0x20 (32) 0x20 (32) 0x20 (32) 0x20 (32) 0x20 (32)
"Tab" 0x09 (9) 0x09 (9) 0x09 (9) 0x09 (9) 0x09 (9) 0x09 (9) 0x09 (9) 0x09 (9)
"Delete" 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46)
"End" 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35)
"Help" N/A N/A 0x2D (45) *2 0x2F (47) *3 0x2D (45) *2 N/A 0x2D (45) *2 0x06 (6) *3
"Home" 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36)
"Insert" 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45)
"PageDown" 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34)
"PageUp" 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33)
"ArrowDown" 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40)
"ArrowLeft" 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37)
"ArrowRight" 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39)
"ArrowUp" 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38)
"Escape" 0x1B (27) 0x1B (27) 0x1B (27) 0x1B (27) 0x1B (27) 0x1B (27) 0x1B (27) 0x1B (27)
"PrintScreen" 0x2C (44) *4 0x2C (44) *4 0x7C (124)*5 0x2A (42) 0x7C (124)*5 0x2C (44) *4 0x2C (44) 0x2A (42)
"ScrollLock" 0x91 (145) 0x91 (145) 0x7D (125)*5 0x91 (145) 0x7D (125)*5 0x91 (145) 0x91 (145) 0x91 (145)
"Pause" 0x13 (19) *6 0x13 (19) *6 0x7E (126)*5 0x13 (19) 0x7E (126)*5 0x13 (19) *6 0x13 (19) 0x13 (19)

*1 keypress事件被激发,其keypcode和charcode为0x10(16),但文本未输入编辑器。
*2在Mac电脑上,“Help”键映射到电脑键盘的“Insert”键。这些keyCode 值与“Insert”键的keyCode值相同。
*3在Fedora 20上测试。
*4仅激发keyup事件。
*5 PC的“PrintScreen”、“ScrollLock”和“Pause”映射到Mac的“F13”、“F14”和“F15”。Chrome和Safari用Mac的键映射相同的keyCode值。
*6“Pause”键加上 Control 导致0x03(3)。

由功能键引起的每个浏览器的keydown事件的keycode值:

{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
{{domxref("KeyboardEvent.code")}} Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
"F1" 0x70 (112) 0x70 (112) 0x70 (112) 0x70 (112) 0x70 (112) 0x70 (112) 0x70 (112) 0x70 (112)
"F2" 0x71 (113) 0x71 (113) 0x71 (113) 0x71 (113) 0x71 (113) 0x71 (113) 0x71 (113) 0x71 (113)
"F3" 0x72 (114) 0x72 (114) 0x72 (114) 0x72 (114) 0x72 (114) 0x72 (114) 0x72 (114) 0x72 (114)
"F4" 0x73 (115) 0x73 (115) 0x73 (115) 0x73 (115) 0x73 (115) 0x73 (115) 0x73 (115) 0x73 (115)
"F5" 0x74 (116) 0x74 (116) 0x74 (116) 0x74 (116) 0x74 (116) 0x74 (116) 0x74 (116) 0x74 (116)
"F6" 0x75 (117) 0x75 (117) 0x75 (117) 0x75 (117) 0x75 (117) 0x75 (117) 0x75 (117) 0x75 (117)
"F7" 0x76 (118) 0x76 (118) 0x76 (118) 0x76 (118) 0x76 (118) 0x76 (118) 0x76 (118) 0x76 (118)
"F8" 0x77 (119) 0x77 (119) 0x77 (119) 0x77 (119) 0x77 (119) 0x77 (119) 0x77 (119) 0x77 (119)
"F9" 0x78 (120) 0x78 (120) 0x78 (120) 0x78 (120) 0x78 (120) 0x78 (120) 0x78 (120) 0x78 (120)
"F10" 0x79 (121) 0x79 (121) 0x79 (121) 0x79 (121) 0x79 (121) 0x79 (121) 0x79 (121) 0x79 (121)
"F11" 0x7A (122) 0x7A (122) 0x7A (122) 0x7A (122) 0x7A (122) 0x7A (122) 0x7A (122) 0x7A (122)
"F12" 0x7B (123) 0x7B (123) 0x7B (123) 0x7B (123) 0x7B (123) 0x7B (123) 0x7B (123) 0x7B (123)
"F13" 0x7C (124) 0x7C (124) 0x7C (124) 0x7C (124) *1 0x7C (124) 0x7C (124) 0x2C (44) *2 0x00 (0) *3
"F14" 0x7D (125) 0x7D (125) 0x7D (125) 0x7D (125) *1 0x7D (125) 0x7D (125) 0x91 (145) *2 0x00 (0) *3
"F15" 0x7E (126) 0x7E (126) 0x7E (126) 0x7E (126) *1 0x7E (126) 0x7E (126) 0x13 (19) *2 0x00 (0) *3
"F16" 0x7F (127) 0x7F (127) 0x7F (127) 0x7F (127) *1 0x7F (127) 0x7F (127) 0x7F (127) 0x00 (0) *3
"F17" 0x80 (128) 0x80 (128) 0x80 (128) 0x80 (128) *1 0x80 (128) 0x80 (128) 0x80 (128) 0x00 (0) *3
"F18" 0x81 (129) 0x81 (129) 0x81 (129) 0x81 (129) *1 0x81 (129) 0x81 (129) 0x81 (129) 0x00 (0) *3
"F19" 0x82 (130) 0x82 (130) 0x82 (130) N/A *4 0x82 (130) 0x82 (130) 0x82 (130) 0x00 (0) *3
"F20" 0x83 (131) 0x83 (131) 0x83 (131) N/A *4 0xE5 (229) *5 0x83 (131) 0x00 (0) N/A *6
"F21" 0x84 (132) 0x84 (132) 0x00 (0) *7 N/A *4 0x00 (0) *7 0x84 (132) N/A *8 N/A *6
"F22" 0x85 (133) 0x85 (133) 0x00 (0) *7 N/A *4 0x00 (0) *7 0x85 (133) N/A *8 N/A *6
"F23" 0x86 (134) 0x86 (134) 0x00 (0) *7 N/A *4 0x00 (0) *7 0x86 (134) N/A *8 N/A *6
"F24" 0x87 (135) 0x87 (135) 0x00 (0) *7 N/A *4 0x00 (0) *7 0x87 (135) N/A *8 0x00 (0) *3

*1在Fedora 20上测试。
*2 PC的“PrintScreen”、“ScrollLock”和“Pause”映射到Mac的“F13”、“F14”和“F15”。火狐映射到和PC相同的keyCode
*3在Fedora 20上测试。这些键不会导致GDK_Fxx 按键符号。如果键产生正确的按键符号,这些值必须与IE相同。
*4在Fedora 20上测试。这些键不会在chromium上引起dom键事件。
*5 keyup事件的keycode值为0x83(131)。
*6在Fedora 20上测试。这些密钥不会在Firefox上引起DOM密钥事件。
*7仅激发keydown事件。
*8在Firefox上不会触发任何DOM密钥事件。

小键盘键

由numPad中的键在numLock状态下导致的每个浏览器的keyDown事件的keycode值

{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
{{domxref("KeyboardEvent.code")}} Windows Windows Mac (10.9) Linux (Ubuntu 14.04) Mac (10.9) Windows Mac (10.9) Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Safari 7 Gecko 29
"NumLock" 0x90 (144) 0x90 (144) 0x0C (12) *1 0x90 (144) 0x0C (12) *1 0x90 (144) 0x0C (12) *1 0x90 (144)
"Numpad0" 0x60 (96) 0x60 (96) 0x60 (96) 0x60 (96) 0x60 (96) 0x60 (96) 0x60 (96) 0x60 (96)
"Numpad1" 0x61 (97) 0x61 (97) 0x61 (97) 0x61 (97) 0x61 (97) 0x61 (97) 0x61 (97) 0x61 (97)
"Numpad2" 0x62 (98) 0x62 (98) 0x62 (98) 0x62 (98) 0x62 (98) 0x62 (98) 0x62 (98) 0x62 (98)
"Numpad3" 0x63 (99) 0x63 (99) 0x63 (99) 0x63 (99) 0x63 (99) 0x63 (99) 0x63 (99) 0x63 (99)
"Numpad4" 0x64 (100) 0x64 (100) 0x64 (100) 0x64 (100) 0x64 (100) 0x64 (100) 0x64 (100) 0x64 (100)
"Numpad5" 0x65 (101) 0x65 (101) 0x65 (101) 0x65 (101) 0x65 (101) 0x65 (101) 0x65 (101) 0x65 (101)
"Numpad6" 0x66 (102) 0x66 (102) 0x66 (102) 0x66 (102) 0x66 (102) 0x66 (102) 0x66 (102) 0x66 (102)
"Numpad7" 0x67 (103) 0x67 (103) 0x67 (103) 0x67 (103) 0x67 (103) 0x67 (103) 0x67 (103) 0x67 (103)
"Numpad8" 0x68 (104) 0x68 (104) 0x68 (104) 0x68 (104) 0x68 (104) 0x68 (104) 0x68 (104) 0x68 (104)
"Numpad9" 0x69 (105) 0x69 (105) 0x69 (105) 0x69 (105) 0x69 (105) 0x69 (105) 0x69 (105) 0x69 (105)
"NumpadAdd" 0x6B (107) 0x6B (107) 0x6B (107) 0x6B (107) 0x6B (107) 0x6B (107) 0x6B (107) 0x6B (107)
"NumpadComma" inputting "," 0xC2 (194) 0xC2 (194) 0xBC (188) Always inputs "." 0xBC (188) 0xC2 (194) 0x6C (108) Always inputs "."
"NumpadComma" inputting "." or empty string 0xC2 (194) 0xC2 (194) 0xBE (190) 0x6E (110) 0xBE (190) 0xC2 (194) 0x6C (108) 0x6E (110)
"NumpadDecimal" inputting "." 0x6E (110) 0x6E (110) 0x6E (110) 0x6E (110) 0x6E (110) 0x6E (110) 0x6E (110) 0x6E (110)
"NumpadDecimal" inputting "," 0x6E (110) 0x6E (110) 0x6E (110) 0x6C (108) 0x6E (110) 0x6E (110) 0x6E (110) 0x6C (108)
"NumpadDivide" 0x6F (111) 0x6F (111) 0x6F (111) 0x6F (111) 0x6F (111) 0x6F (111) 0x6F (111) 0x6F (111)
"NumpadEnter" 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13) 0x0D (13)
"NumpadEqual" 0x0C (12) 0x0C (12) 0xBB (187) 0xBB (187) 0xBB (187) 0x0C (12) 0x3D (61) 0x3D (61)
"NumpadMultiply" 0x6A (106) 0x6A (106) 0x6A (106) 0x6A (106) 0x6A (106) 0x6A (106) 0x6A (106) 0x6A (106)
"NumpadSubtract" 0x6D (109) 0x6D (109) 0x6D (109) 0x6D (109) 0x6D (109) 0x6D (109) 0x6D (109) 0x6D (109)

*1“numlock”键在Mac上作为“clear”键工作。

由处于无numlock状态的numpad中的键引起的每个浏览器的keydown事件的keycode值

{{domxref("KeyboardEvent.code")}} Internet Explorer 11 Google Chrome 34 Chromium 34 Gecko 29
Windows Windows Linux (Ubuntu 14.04) Windows Linux (Ubuntu 14.04)
{{domxref("KeyboardEvent.code")}} Windows Windows Linux (Ubuntu 14.04) Windows Linux (Ubuntu 14.04)
Internet Explorer 11 Google Chrome 34 Chromium 34 Gecko 29
"Numpad0" ("Insert") 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45) 0x2D (45)
"Numpad1" ("End") 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35) 0x23 (35)
"Numpad2" ("ArrowDown") 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40) 0x28 (40)
"Numpad3" ("PageDown") 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34) 0x22 (34)
"Numpad4" ("ArrowLeft") 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37) 0x25 (37)
"Numpad5" 0x0C (12) 0x0C (12) 0x0C (12) 0x0C (12) 0x0C (12)
"Numpad6" ("ArrowRight") 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39) 0x27 (39)
"Numpad7" ("Home") 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36) 0x24 (36)
"Numpad8" ("ArrowUp") 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38) 0x26 (38)
"Numpad9" ("PageUp") 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33) 0x21 (33)
"NumpadDecimal" ("Delete") 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46) 0x2E (46)

*最近的Mac没有“numlock”键和状态。因此,未锁定状态不可用。

常数值的键码

gecko在keyboardvent中定义了许多keycode值,用于显式地生成映射表。这些值对Firefox的附加开发人员很有用,但在公共网页中却没有那么有用。

常数 描述
DOM_VK_CANCEL 0x03 (3) Cancel key.
DOM_VK_HELP 0x06 (6) Help key.
DOM_VK_BACK_SPACE 0x08 (8) Backspace key.
DOM_VK_TAB 0x09 (9) Tab key.
DOM_VK_CLEAR 0x0C (12) "5" key on Numpad when NumLock is unlocked. Or on Mac, clear key which is positioned at NumLock key.
DOM_VK_RETURN 0x0D (13) Return/enter key on the main keyboard.
DOM_VK_ENTER 0x0E (14) Reserved, but not used. {{obsolete_inline(30)}} (Dropped, see {{bug(969247)}}.)
DOM_VK_SHIFT 0x10 (16) Shift key.
DOM_VK_CONTROL 0x11 (17) Control key.
DOM_VK_ALT 0x12 (18) Alt (Option on Mac) key.
DOM_VK_PAUSE 0x13 (19) Pause key.
DOM_VK_CAPS_LOCK 0x14 (20) Caps lock.
DOM_VK_KANA 0x15 (21) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_HANGUL 0x15 (21) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_EISU 0x 16 (22) "英数" key on Japanese Mac keyboard. {{gecko_minversion_inline("15.0")}}
DOM_VK_JUNJA 0x17 (23) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_FINAL 0x18 (24) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_HANJA 0x19 (25) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_KANJI 0x19 (25) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_ESCAPE 0x1B (27) Escape key.
DOM_VK_CONVERT 0x1C (28) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_NONCONVERT 0x1D (29) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_ACCEPT 0x1E (30) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_MODECHANGE 0x1F (31) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_SPACE 0x20 (32) Space bar.
DOM_VK_PAGE_UP 0x21 (33) Page Up key.
DOM_VK_PAGE_DOWN 0x22 (34) Page Down key.
DOM_VK_END 0x23 (35) End key.
DOM_VK_HOME 0x24 (36) Home key.
DOM_VK_LEFT 0x25 (37) Left arrow.
DOM_VK_UP 0x26 (38) Up arrow.
DOM_VK_RIGHT 0x27 (39) Right arrow.
DOM_VK_DOWN 0x28 (40) Down arrow.
DOM_VK_SELECT 0x29 (41) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_PRINT 0x2A (42) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_EXECUTE 0x2B (43) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_PRINTSCREEN 0x2C (44) Print Screen key.
DOM_VK_INSERT 0x2D (45) Ins(ert) key.
DOM_VK_DELETE 0x2E (46) Del(ete) key.
DOM_VK_0 0x30 (48) "0" key in standard key location.
DOM_VK_1 0x31 (49) "1" key in standard key location.
DOM_VK_2 0x32 (50) "2" key in standard key location.
DOM_VK_3 0x33 (51) "3" key in standard key location.
DOM_VK_4 0x34 (52) "4" key in standard key location.
DOM_VK_5 0x35 (53) "5" key in standard key location.
DOM_VK_6 0x36 (54) "6" key in standard key location.
DOM_VK_7 0x37 (55) "7" key in standard key location.
DOM_VK_8 0x38 (56) "8" key in standard key location.
DOM_VK_9 0x39 (57) "9" key in standard key location.
DOM_VK_COLON 0x3A (58) Colon (":") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_SEMICOLON 0x3B (59) Semicolon (";") key.
DOM_VK_LESS_THAN 0x3C (60) Less-than ("<") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_EQUALS 0x3D (61) Equals ("=") key.
DOM_VK_GREATER_THAN 0x3E (62) Greater-than (">") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_QUESTION_MARK 0x3F (63) Question mark ("?") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_AT 0x40 (64) Atmark ("@") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_A 0x41 (65) "A" key.
DOM_VK_B 0x42 (66) "B" key.
DOM_VK_C 0x43 (67) "C" key.
DOM_VK_D 0x44 (68) "D" key.
DOM_VK_E 0x45 (69) "E" key.
DOM_VK_F 0x46 (70) "F" key.
DOM_VK_G 0x47 (71) "G" key.
DOM_VK_H 0x48 (72) "H" key.
DOM_VK_I 0x49 (73) "I" key.
DOM_VK_J 0x4A (74) "J" key.
DOM_VK_K 0x4B (75) "K" key.
DOM_VK_L 0x4C (76) "L" key.
DOM_VK_M 0x4D (77) "M" key.
DOM_VK_N 0x4E (78) "N" key.
DOM_VK_O 0x4F (79) "O" key.
DOM_VK_P 0x50 (80) "P" key.
DOM_VK_Q 0x51 (81) "Q" key.
DOM_VK_R 0x52 (82) "R" key.
DOM_VK_S 0x53 (83) "S" key.
DOM_VK_T 0x54 (84) "T" key.
DOM_VK_U 0x55 (85) "U" key.
DOM_VK_V 0x56 (86) "V" key.
DOM_VK_W 0x57 (87) "W" key.
DOM_VK_X 0x58 (88) "X" key.
DOM_VK_Y 0x59 (89) "Y" key.
DOM_VK_Z 0x5A (90) "Z" key.
DOM_VK_WIN 0x5B (91) Windows logo key on Windows. Or Super or Hyper key on Linux. {{gecko_minversion_inline("15.0")}}
DOM_VK_CONTEXT_MENU 0x5D (93) Opening context menu key.
DOM_VK_SLEEP 0x5F (95) Linux support for this keycode was added in Gecko 4.0.
DOM_VK_NUMPAD0 0x60 (96) "0" on the numeric keypad.
DOM_VK_NUMPAD1 0x61 (97) "1" on the numeric keypad.
DOM_VK_NUMPAD2 0x62 (98) "2" on the numeric keypad.
DOM_VK_NUMPAD3 0x63 (99) "3" on the numeric keypad.
DOM_VK_NUMPAD4 0x64 (100) "4" on the numeric keypad.
DOM_VK_NUMPAD5 0x65 (101) "5" on the numeric keypad.
DOM_VK_NUMPAD6 0x66 (102) "6" on the numeric keypad.
DOM_VK_NUMPAD7 0x67 (103) "7" on the numeric keypad.
DOM_VK_NUMPAD8 0x68 (104) "8" on the numeric keypad.
DOM_VK_NUMPAD9 0x69 (105) "9" on the numeric keypad.
DOM_VK_MULTIPLY 0x6A (106) "*" on the numeric keypad.
DOM_VK_ADD 0x6B (107) "+" on the numeric keypad.
DOM_VK_SEPARATOR 0x6C (108)
DOM_VK_SUBTRACT 0x6D (109) "-" on the numeric keypad.
DOM_VK_DECIMAL 0x6E (110) Decimal point on the numeric keypad.
DOM_VK_DIVIDE 0x6F (111) "/" on the numeric keypad.
DOM_VK_F1 0x70 (112) F1 key.
DOM_VK_F2 0x71 (113) F2 key.
DOM_VK_F3 0x72 (114) F3 key.
DOM_VK_F4 0x73 (115) F4 key.
DOM_VK_F5 0x74 (116) F5 key.
DOM_VK_F6 0x75 (117) F6 key.
DOM_VK_F7 0x76 (118) F7 key.
DOM_VK_F8 0x77 (119) F8 key.
DOM_VK_F9 0x78 (120) F9 key.
DOM_VK_F10 0x79 (121) F10 key.
DOM_VK_F11 0x7A (122) F11 key.
DOM_VK_F12 0x7B (123) F12 key.
DOM_VK_F13 0x7C (124) F13 key.
DOM_VK_F14 0x7D (125) F14 key.
DOM_VK_F15 0x7E (126) F15 key.
DOM_VK_F16 0x7F (127) F16 key.
DOM_VK_F17 0x80 (128) F17 key.
DOM_VK_F18 0x81 (129) F18 key.
DOM_VK_F19 0x82 (130) F19 key.
DOM_VK_F20 0x83 (131) F20 key.
DOM_VK_F21 0x84 (132) F21 key.
DOM_VK_F22 0x85 (133) F22 key.
DOM_VK_F23 0x86 (134) F23 key.
DOM_VK_F24 0x87 (135) F24 key.
DOM_VK_NUM_LOCK 0x90 (144) Num Lock key.
DOM_VK_SCROLL_LOCK 0x91 (145) Scroll Lock key.
DOM_VK_WIN_OEM_FJ_JISHO 0x92 (146) An OEM specific key on Windows. This was used for "Dictionary" key on Fujitsu OASYS. {{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_FJ_MASSHOU 0x93 (147) An OEM specific key on Windows. This was used for "Unregister word" key on Fujitsu OASYS. {{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_FJ_TOUROKU 0x94 (148) An OEM specific key on Windows. This was used for "Register word" key on Fujitsu OASYS. {{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_FJ_LOYA 0x95 (149) An OEM specific key on Windows. This was used for "Left OYAYUBI" key on Fujitsu OASYS. {{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_FJ_ROYA 0x96 (150) An OEM specific key on Windows. This was used for "Right OYAYUBI" key on Fujitsu OASYS. {{gecko_minversion_inline("21.0")}}
DOM_VK_CIRCUMFLEX 0xA0 (160) Circumflex ("^") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_EXCLAMATION 0xA1 (161) Exclamation ("!") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_DOUBLE_QUOTE 0xA3 (162) Double quote (""") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_HASH 0xA3 (163) Hash ("#") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_DOLLAR 0xA4 (164) Dollar sign ("$") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_PERCENT 0xA5 (165) Percent ("%") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_AMPERSAND 0xA6 (166) Ampersand ("&") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_UNDERSCORE 0xA7 (167) Underscore ("_") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_OPEN_PAREN 0xA8 (168) Open parenthesis ("(") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_CLOSE_PAREN 0xA9 (169) Close parenthesis (")") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_ASTERISK 0xAA (170) Asterisk ("*") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_PLUS 0xAB (171) Plus ("+") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_PIPE 0xAC (172) Pipe ("|") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_HYPHEN_MINUS 0xAD (173) Hyphen-US/docs/Minus ("-") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_OPEN_CURLY_BRACKET 0xAE (174) Open curly bracket ("{") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_CLOSE_CURLY_BRACKET 0xAF (175) Close curly bracket ("}") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_TILDE 0xB0 (176) Tilde ("~") key. {{gecko_minversion_inline("15.0")}}
DOM_VK_VOLUME_MUTE 0xB5 (181) Audio mute key. {{gecko_minversion_inline("21.0")}}
DOM_VK_VOLUME_DOWN 0xB6 (182) Audio volume down key {{gecko_minversion_inline("21.0")}}
DOM_VK_VOLUME_UP 0xB7 (183) Audio volume up key {{gecko_minversion_inline("21.0")}}
DOM_VK_COMMA 0xBC (188) Comma (",") key.
DOM_VK_PERIOD 0xBE (190) Period (".") key.
DOM_VK_SLASH 0xBF (191) Slash ("/") key.
DOM_VK_BACK_QUOTE 0xC0 (192) Back tick ("`") key.
DOM_VK_OPEN_BRACKET 0xDB (219) Open square bracket ("[") key.
DOM_VK_BACK_SLASH 0xDC (220) Back slash ("\") key.
DOM_VK_CLOSE_BRACKET 0xDD (221) Close square bracket ("]") key.
DOM_VK_QUOTE 0xDE (222) Quote (''') key.
DOM_VK_META 0xE0 (224) Meta key on Linux, Command key on Mac.
DOM_VK_ALTGR 0xE1 (225) AltGr key (Level 3 Shift key or Level 5 Shift key) on Linux. {{gecko_minversion_inline("15.0")}}
DOM_VK_WIN_ICO_HELP 0xE3 (227) An OEM specific key on Windows. This is (was?) used for Olivetti ICO keyboard.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_ICO_00 0xE4 (228) An OEM specific key on Windows. This is (was?) used for Olivetti ICO keyboard.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_ICO_CLEAR 0xE6 (230) An OEM specific key on Windows. This is (was?) used for Olivetti ICO keyboard.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_RESET 0xE9 (233) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_JUMP 0xEA (234) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_PA1 0xEB (235) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_PA2 0xEC (236) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_PA3 0xED (237) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_WSCTRL 0xEE (238) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_CUSEL 0xEF (239) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_ATTN 0xF0 (240) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_FINISH 0xF1 (241) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_COPY 0xF2 (242) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_AUTO 0xF3 (243) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_ENLW 0xF4 (244) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_BACKTAB 0xF5 (245) An OEM specific key on Windows. This was used for Nokia/Ericsson's device.{{gecko_minversion_inline("21.0")}}
DOM_VK_ATTN 0xF6 (246) Attn (Attention) key of IBM midrange computers, e.g., AS/400. {{gecko_minversion_inline("21.0")}}
DOM_VK_CRSEL 0xF7 (247) CrSel (Cursor Selection) key of IBM 3270 keyboard layout. {{gecko_minversion_inline("21.0")}}
DOM_VK_EXSEL 0xF8 (248) ExSel (Extend Selection) key of IBM 3270 keyboard layout. {{gecko_minversion_inline("21.0")}}
DOM_VK_EREOF 0xF9 (249) Erase EOF key of IBM 3270 keyboard layout. {{gecko_minversion_inline("21.0")}}
DOM_VK_PLAY 0xFA (250) Play key of IBM 3270 keyboard layout. {{gecko_minversion_inline("21.0")}}
DOM_VK_ZOOM 0xFB (251) Zoom key. {{gecko_minversion_inline("21.0")}}
DOM_VK_PA1 0xFD (253) PA1 key of IBM 3270 keyboard layout. {{gecko_minversion_inline("21.0")}}
DOM_VK_WIN_OEM_CLEAR 0xFE (254) Clear key, but we're not sure the meaning difference from DOM_VK_CLEAR. {{gecko_minversion_inline("21.0")}}

Windows上的OEM特定密钥

在Windows上,虚拟密钥代码的某些值是为特定于OEM的密钥定义(保留)的。它们可用于非标准键盘上的特殊键。换句话说,一些值被两个或多个供应商(或硬件)用于不同的含义。

从gecko 21(并且早于15)开始,仅在Windows上的keycode属性上提供OEM特定的键值。因此,它们对于通常的Web应用程序不有用。它们仅对内部网应用程序或类似情况有用。

查看MSDN上的"Manufacturer-specific Virtual-Key Codes (Windows CE 5.0)"了解更多