W3C

Legacy Keyboard Event Properties

W3C Working Group Note 04 August 2010

This version:
https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/Note-KeyProps.html
Latest version:
https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/Note-KeyProps.html
Editor:
Doug Schepers, W3C

Abstract

This document describes the legacy key event properties keyCode and charCode, their values in some common browsers, and how they correspond to the key event property values defined in the DOM Level 3 Events [DOM3 Events] specification.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document is a Working Group Note. It has been developed by the Web Applications WG, as part of the Rich Web Clients Activity in the W3C Interaction Domain. Please send comments on this document to the WebApps Working Group's public email list www-dom@w3.org (public archives).

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

Table of Contents


1. Introduction

Browser support for keyboards has traditionally relied on two ad-hoc event interface properties, keyCode, and charCode. The values for these properties, and the availability of the attribute, is inconsistent across platforms, keyboard languages and layouts, user agents, versions, and even event types. A significant amount of legacy content, including script libraries, relies upon detecting the user agent and acting accordingly, and any changes to keyCode, or charCode risk breaking as much content as they fix or enable. Additionally, these properties are not suitable for international usage, or accessibility concerns. Therefore, the DOM Level 3 Events [DOM3 Events] specification does not normatively define the keyCode, and charCode properties, relying instead only on the more robust key values, which can be used safely and consistently in any user agent which conforms to that specification. However, for the purpose of documenting the current state of these properties and their relation to equivalent key values, this note contains the following table, which is to be used as an informative reference only, and does not document the full range of values for keyCode, and charCode.

1.1. Key values, keyCode, and charCode

Note: This section is non-normative.

Key Values Set with keyCode and charCode Equivalents for Major Browsers
(keycode labeled key, charcode labeled char)
Glyph Key Name Character Value Description Internet Explorer 7 Firefox 3 Safari 3.1 Opera 9.5
keydown keypress keyup keydown keypress keyup keydown keypress keyup keydown keypress keyup
keycharkeycharkeycharkeycharkeycharkeycharkeycharkeycharkeycharkeycharkeycharkeychar
'Accept' The Accept (Commit, OK) key.
'Add' The Add key.107-107-107-107-0107107-107-107107107-107-107-107-
'Again' The Again key.
'AllCandidates' The All Candidates key.
'Alphanumeric' The Alphanumeric key.
'Alt' The Alt (Menu) key.18---18-18---18-18---18-18-18---
'AltGraph' The Alt-Graph key.
'Apps' The Application key.
'Attn' The ATTN key.
'BrowserBack' The Browser Back key.
'BrowserFavorites' The Browser Favorites key.
'BrowserForward' The Browser Forward key.
'BrowserHome' The Browser Home key.36---36-36-36-36-36---36-36-36-36-
'BrowserRefresh' The Browser Refresh key.
'BrowserSearch' The Browser Search key.
'BrowserStop' The Browser Stop key.
'CapsLock' The Caps Lock (Capital) key.20---20-20---20-20---20-20---20-
'Clear' The Clear key.
'CodeInput' The Code Input key.
'Compose' The Compose key.
'Control' The Control (Ctrl) key.17---17-17---17-17---17-17-17-17-
'Crsel' The Crsel key.
'Convert' The Convert key.
'Copy' The Copy key.
'Cut' The Cut key.
'Decimal' The Decimal key.110-110-110-110-0110110-110-110110110-110-110-110-
'Divide' The Divide key.111-111-111-111-0111111-111-111111111-111-111-111-
'Down' The Down Arrow key.
'DownLeft' The diagonal Down-Left Arrow key.
'DownRight' The diagonal Down-Right Arrow key.
'End' The End key.35---35-35-35-35-35---35-35-35-35-
'Enter' The Enter key. Note: This key value shall be also used for the Return (Macintosh numpad) key.13-13-13-13-13-13-13-131313-13-13-13-
'EraseEof' The Erase EOF key.
'Execute' The Execute key.
'Exsel' The Exsel key.
'Fn' The Function switch key.------------------------
'F1' The F1 key.112---112-112-112-112-112---112-112-112-112-
'F2' The F2 key.113---113-113-113-113-113---113-113-113-113-
'F3' The F3 key.114---114-114-114-114-114---114-114-114-114-
'F4' The F4 key.115---115-115-115-115-115---115-115-115-115-
'F5' The F5 key.116---116-116-116-116-116---116-116-116-116-
'F6' The F6 key.117---117-117-117-117-117---117-117-117-117-
'F7' The F7 key.118---118-118-118-118-118---118-118-118-118-
'F8' The F8 key.119---119-119-119-119-119---119-119-119-119-
'F9' The F9 key.120---120-120-120-120-120---120-120-120-120-
'F10' The F10 key.121---121-121-121-121-121---121-121-121-121-
'F11' The F11 key.122---122-122-122-122-122---122-122-122-122-
'F12' The F12 key.123---123-123-123-123-123---123-123-123-123-
'F13' The F13 key.124---124-124-124-124-124---124-124-124-124-
'F14' The F14 key.125---125-125-125-125-125---125-125-125-125-
'F15' The F15 key.126---126-126-126-126-126---126-126-126-126-
'F16' The F16 key.127---127-127-127-127-127---127-127-127-127-
'F17' The F17 key.128---128-128-128-128-128---128-128-128-128-
'F18' The F18 key.129---129-129-129-129-129---129-129-129-129-
'F19' The F19 key.130---130-130-130-130-130---130-130-130-130-
'F20' The F20 key.131---131-131-131-131-131---131-131-131-131-
'F21' The F21 key.132---132-132-132-132-132---132-132-132-132-
'F22' The F22 key.133---133-133-133-133-133---133-133-133-133-
'F23' The F23 key.134---134-134-134-134-134---134-134-134-134-
'F24' The F24 key.135---135-135-135-135-135---135-135-135-135-
'FinalMode' The Final Mode (Final) key used on some asian keyboards.
'Find' The Find key.
'FullWidth' The Full-Width Characters key.
'HalfWidth' The Half-Width Characters key.
'HangulMode' The Hangul (Korean characters) Mode key.
'HanjaMode' The Hanja (Korean characters) Mode key.
'Help' The Help key.
'Hiragana' The Hiragana (Japanese Kana characters) key.
'Home' The Home key.
'Insert' The Insert (Ins) key.45---45-45-45-45-45---45-45-45-45-
'JapaneseHiragana' The Japanese-Hiragana key.
'JapaneseKatakana' The Japanese-Katakana key.
'JapaneseRomaji' The Japanese-Romaji key.
'JunjaMode' The Junja Mode key.
'KanaMode' The Kana Mode (Kana Lock) key.
'KanjiMode' The Kanji (Japanese name for ideographic characters of Chinese origin) Mode key.
'Katakana' The Katakana (Japanese Kana characters) key.
'LaunchApplication1' The Start Application One key.
'LaunchApplication2' The Start Application Two key.
'LaunchMail' The Start Mail key.
'Left' The Left Arrow key.
'Menu' The Menu key.
'Meta' The Meta key.
'MediaNextTrack' The Media Next Track key.
'MediaPlayPause' The Media Play Pause key.
'MediaPreviousTrack' The Media Previous Track key.
'MediaStop' The Media Stop key.
'ModeChange' The Mode Change key.
'Multiply' The Multiply key.106-106-106-106-0106106-106-106106106-106-106-106-
'NextCandidate' The Next Candidate function key.
'Nonconvert' The Nonconvert (Don't Convert) key.
'NumLock' The Number Lock key.
'PageDown' The Page Down (Next) key.
'PageUp' The Page Up key.33---33-33-33-33-33---33-33-33-33-
'Paste' The Paste key.
'Pause' The Pause key.19---19-19-19-19-19---19-19-19-19-
'Play' The Play key.
'PreviousCandidate' The Previous Candidate function key.
'PrintScreen' The Print Screen (PrintScrn, SnapShot) key.
'Process' The Process key.
'Props' The Props key.
'Right' The Right Arrow key.
'RomanCharacters' The Roman Characters function key.
'Scroll' The Scroll Lock key.
'Select' The Select key.
'SelectMedia' The Select Media key.
'Separator' The Separator key.108-108-108-108-0108108-108-108108108-108-108-108-
'Shift' The Shift key.17---17-17---17-17---17-17-17-17-
'Soft1' The Soft1 key.
'Soft2' The Soft2 key.
'Soft3' The Soft3 key.
'Soft4' The Soft4 key.
'Stop' The Stop key.
'Subtract' The Subtract key.109-109-109-109-0109109-109-109109109-109-109-109-
'Up' The Up Arrow key.
'UpLeft' The diagonal Up-Left Arrow key.
'UpRight' The diagonal Up-Right Arrow key.
'Undo' The Undo key.
'VolumeDown' The Volume Down key.
'VolumeMute' The Volume Mute key.
'VolumeUp' The Volume Up key.
'Win' The Windows Logo key.
'Zoom' The Zoom key.
'Backspace' '\u0008' The Backspace (Back) key.8---8-8-8-8-8---8-8-8-8-
'Tab' '\u0009' The Horizontal Tabulation (Tab) key.9-----9-9---9-----9-9---
'Cancel' '\u0018' The Cancel key.
'Esc' '\u001B' The Escape (Esc) key.27-27-27-27-27-27-27---27-27-27-27-
'Spacebar' '\u0020' The Space (Spacebar) key.32-32-32-32-03232-32-323232-32-32-32-
'!' 'Exclamation' '\u0021' The Exclamation Mark (Factorial, Bang) key.49-33-49-49-03349-49-333349-49-33-49-
" 'DoubleQuote' '\u0022' The Quotation Mark (Quote Double) key. Note: May need to be escaped as an attribute value.50-34-50-50-03450-50-343450-50-34-50-
'#' 'Hash' '\u0023' The Number Sign (Pound Sign, Hash, Crosshatch, Octothorpe) key.51-35-51-51-03551-51-353551-51-35-51-
'$' 'Dollar' '\u0024' The Dollar Sign (milreis, escudo) key.52-36-52-52-03652-52-363652-52-36-52-
'&' 'Ampersand' '\u0026' The Ampersand key.54-38-54-54-03854-54-383854-54-38-54-
' 'Apostrophe' '\u0027' The Apostrophe (Apostrophe-Quote, APL Quote) key. Note: May need to be escaped as an attribute value.191-39-191-191-039191-191-3939191-222-39-222-
'(' 'LeftParen' '\u0028' The Left Parenthesis (Opening Parenthesis) key.56-40-56-56-04056-56-404056-56-40-56-
')' 'RightParen' '\u0029' The Right Parenthesis (Closing Parenthesis) key.57-41-57-57-04157-57-414157-57-41-57-
'*' 'Asterisk' '\u002A' The Asterisk (Star) key: in number pad.106-42-106-106-042106-106-4242106-42-42-42-
'+' 'Plus' '\u002B' The Plus Sign (Plus) key.
'%' 'Percent' '\u0025' The Percent key.53-37-53-53-03753-53-373753-53-37-53-
',' 'Comma' '\u002C' The Comma (decimal separator) sign key.188-44-188-188-044188-188-4444188-188-44-188-
'-' 'HyphenMinus' '\u002D' The Hyphen-minus (hyphen or minus sign) key.
'.' 'Period' '\u002E' The Full Stop (period, dot, decimal point) key.190-46-190-190-046190-190-4646190-190-46-190-
'/' 'Solidus' '\u002F' The Solidus (slash, virgule, shilling) key.55-47-55-55-04755-55-474755-55-47-55-
'0' '\u0030' The Digit Zero key.48484848484848-04848-48-484848-48-48-48-
'1' '\u0031' The Digit One key.49494949494949-04949-49-494949-49-49-49-
'2' '\u0032' The Digit Two key.50505050505050-05050-50-505050-50-50-50-
'3' '\u0033' The Digit Three key.51515151515151-05151-51-515151-51-51-51-
'4' '\u0034' The Digit Four key.52525252525252-05252-52-525252-52-52-52-
'5' '\u0035' The Digit Five key.53535353535353-05353-53-535353-53-53-53-
'6' '\u0036' The Digit Six key.54545454545454-05454-54-545454-54-54-54-
'7' '\u0037' The Digit Seven key.55555555555555-05555-55-555555-55-55-55-
'8' '\u0038' The Digit Eight key.56565656565656-05656-56-565656-56-56-56-
'9' '\u0039' The Digit Nine key.57575757575757-05757-57-575757-57-57-57-
':' 'Colon' '\u003A' The Colon key.190-58-190-190-058190-190-5858190-190-58-190-
';' 'Semicolon' '\u003B' The Semicolon key.188-59-188-188-059188-188-5959188-188-59-188-
'<' 'LessThan' '\u003C' The Less-Than Sign key: <.188-60-188-188-060188-188-6060188-188-60-188-
'=' 'Equals' '\u003D' The Equals Sign key.48-61-48-48-06148-48-616148-48-61-48-
'>' 'GreaterThan' '\u003E' The Greater-Than Sign key: >.226-62-226-226-062226-226-6262226-188-62-188-
'?' 'QuestionMark' '\u003F' The Question Mark key.191-63-191-107-063107-191-6363191-61-63-61-
'@' 'At' '\u0040' The Commercial At key.50-64-50-50-06450-50-646450-50-64-50-
'A' '\u0041' The Latin Capital Letter A key.65656565656565-06565-65-656565-65-65-65-
'B' '\u0042' The Latin Capital Letter B key.66666666666666-06666-66-666666-66-66-66-
'C' '\u0043' The Latin Capital Letter C key.67676767676767-06767-67-676767-67-67-67-
'D' '\u0044' The Latin Capital Letter D key.68686868686868-06868-68-686868-68-68-68-
'E' '\u0045' The Latin Capital Letter E key.69696969696969-06969-69-696969-69-69-69-
'F' '\u0046' The Latin Capital Letter F key.70707070707070-07070-70-707070-70-70-70-
'G' '\u0047' The Latin Capital Letter G key.71717171717171-07171-71-717171-71-71-71-
'H' '\u0048' The Latin Capital Letter H key.72727272727272-07272-72-727272-72-72-72-
'I' '\u0049' The Latin Capital Letter I key.73737373737373-07373-73-737373-73-73-73-
'J' '\u004A' The Latin Capital Letter J key.74747474747474-07474-74-747474-74-74-74-
'K' '\u004B' The Latin Capital Letter K key.75757575757575-07575-75-757575-75-75-75-
'L' '\u004C' The Latin Capital Letter L key.76767676767676-07676-76-767676-76-76-76-
'M' '\u004D' The Latin Capital Letter M key.77777777777777-07777-77-777777-77-77-77-
'N' '\u004E' The Latin Capital Letter N key.78787878787878-07878-78-787878-78-78-78-
'O' '\u004F' The Latin Capital Letter O key.79797979797979-07979-79-797979-79-79-79-
'P' '\u0050' The Latin Capital Letter P key.80808080808080-08080-80-808080-80-80-80-
'Q' '\u0051' The Latin Capital Letter Q key.81818181818181-08181-81-818181-81-81-81-
'R' '\u0052' The Latin Capital Letter R key.82828282828282-08282-82-828282-82-82-82-
'S' '\u0053' The Latin Capital Letter S key.83838383838383-08383-83-838383-83-83-83-
'T' '\u0054' The Latin Capital Letter T key.84848484848484-08484-84-848484-84-84-84-
'U' '\u0055' The Latin Capital Letter U key.85858585858585-08585-85-858585-85-85-85-
'V' '\u0056' The Latin Capital Letter V key.86868686868686-08686-86-868686-86-86-86-
'W' '\u0057' The Latin Capital Letter W key.87878787878787-08787-87-878787-87-87-87-
'X' '\u0058' The Latin Capital Letter X key.88888888888888-08888-88-888888-88-88-88-
'Y' '\u0059' The Latin Capital Letter Y key.89898989898989-08989-89-898989-89-89-89-
'Z' '\u005A' The Latin Capital Letter Z key.90909090909090-09090-90-909090-90-90-90-
'a' '\u0061' The Latin Small Letter A key: a.65656565656565-09765-65-979765-65-97-65-
'b' '\u0062' The Latin Small Letter B key: b.66666666666666-09866-66-989866-66-98-66-
'c' '\u0063' The Latin Small Letter C key: c.67676767676767-09967-67-999967-67-99-67-
'd' '\u0064' The Latin Small Letter D key: d.68686868686868-010068-68-10010068-68-100-68-
'e' '\u0065' The Latin Small Letter E key: e.69696969696969-010169-69-10110169-69-101-69-
'f' '\u0066' The Latin Small Letter F key: f.70707070707070-010270-70-10210270-70-102-70-
'g' '\u0067' The Latin Small Letter G key: g.71717171717171-010371-71-10310371-71-103-71-
'h' '\u0068' The Latin Small Letter H key: h.72727272727272-010472-72-10410472-72-104-72-
'i' '\u0069' The Latin Small Letter I key: i.73737373737373-010573-73-10510573-73-105-73-
'j' '\u006A' The Latin Small Letter J key: j.74747474747474-010674-74-10610674-74-106-74-
'k' '\u006B' The Latin Small Letter K key: k.75757575757575-010775-75-10710775-75-107-75-
'l' '\u006C' The Latin Small Letter L key: l.76767676767676-010876-76-10810876-76-108-76-
'm' '\u006D' The Latin Small Letter M key: m.77777777777777-010977-77-10910977-77-109-77-
'n' '\u006E' The Latin Small Letter N key: n.78787878787878-011078-78-11011078-78-110-78-
'o' '\u006F' The Latin Small Letter O key: o.79797979797979-011179-79-11111179-79-111-79-
'p' '\u0070' The Latin Small Letter P key: p.80808080808080-011280-80-11211280-80-112-80-
'q' '\u0071' The Latin Small Letter Q key: q.81818181818181-011381-81-11311381-81-113-81-
'r' '\u0072' The Latin Small Letter R key: r.82828282828282-011482-82-11411482-82-114-82-
's' '\u0073' The Latin Small Letter S key: s.83838383838383-011583-83-11511583-83-115-83-
't' '\u0074' The Latin Small Letter T key: t.84848484848484-011684-84-11611684-84-116-84-
'u' '\u0075' The Latin Small Letter U key: u.85858585858585-011785-85-11711785-85-117-85-
'v' '\u0076' The Latin Small Letter V key: v.86868686868686-011886-86-11811886-86-118-86-
'w' '\u0077' The Latin Small Letter W key: w.87878787878787-011987-87-11911987-87-119-87-
'x' '\u0078' The Latin Small Letter X key: x.88888888888888-012088-88-12012088-88-120-88-
'y' '\u0079' The Latin Small Letter Y key: y.89898989898989-012189-89-12112189-89-121-89-
'z' '\u007A' The Latin Small Letter Z key: z.90909090909090-012290-90-12212290-90-122-90-
'[' 'LeftSquareBracket' '\u005B' The Left Square Bracket (Opening Square Bracket) key.56-91-56-56-09156-56-919156-56-91-56-
'\' 'Backslash' '\u005C' The Reverse Solidus (Backslash) key.187-92-187-107-92-107-187-9292187-161-92-161-
']' 'RightSquareBracket' '\u005D' The Right Square Bracket (Closing Square Bracket) key.57-93-57-57-09357-57-939357-57-93-57-
'^' 'Circumflex' '\u005E' The Circumflex Accent key.186-94-186-59-09459-186-9494186-168-94-168-
'_' 'Underscore' '\u005F' The Low Sign (Spacing Underscore, Underscore) key.
'`' 'Grave' '\u0060' The Grave Accent (Back Quote) key.
'{' 'LeftCurlyBracket' '\u007B' The Left Curly Bracket (Opening Curly Bracket, Opening Brace, Brace Left) key.55-123-55-55-012355-55-12312355-55-123-55-
'|' 'Pipe' '\u007C' The Vertical Line (Vertical Bar, Pipe) key.226-124-226-226-0124226-226-124124226-188-124-188-
'}' 'RightCurlyBracket' '\u007D' The Right Curly Bracket (Closing Curly Bracket, Closing Brace, Brace Right) key.48-125-48-48-012548-48-12512548-48-125-48-
'Del' '\u007F' The Delete (Del) Key.46---46-46-46-46-46---46-46-46-46-
'¡' 'InvertedExclamation' '\u00A1' The Inverted Exclamation Mark key.
'DeadGrave' '\u0300' The Combining Grave Accent (Greek Varia, Dead Grave) key.
'DeadEacute' '\u0301' The Combining Acute Accent (Stress Mark, Greek Oxia, Tonos, Dead Eacute) key.
'DeadCircumflex' '\u0302' The Combining Circumflex Accent (Hat, Dead Circumflex) key.
'DeadTilde' '\u0303' The Combining Tilde (Dead Tilde) key.
'DeadMacron' '\u0304' The Combining Macron (Long, Dead Macron) key.
'DeadBreve' '\u0306' The Combining Breve (Short, Dead Breve) key.
'DeadAboveDot' '\u0307' The Combining Dot Above (Derivative, Dead Above Dot) key.
'DeadUmlaut' '\u0308' The Combining Diaeresis (Double Dot Abode, Umlaut, Greek Dialytika, Double Derivative, Dead Diaeresis) key.
'DeadAboveRing' '\u030A' The Combining Ring Above (Dead Above Ring) key.
'DeadDoubleacute' '\u030B' The Combining Double Acute Accent (Dead Doubleacute) key.
'DeadCaron' '\u030C' The Combining Caron (Hacek, V Above, Dead Caron) key.
'DeadCedilla' '\u0327' The Combining Cedilla (Dead Cedilla) key.
'DeadOgonek' '\u0328' The Combining Ogonek (Nasal Hook, Dead Ogonek) key.
'DeadIota' '\u0345' The Combining Greek Ypogegrammeni (Greek Non-Spacing Iota Below, Iota Subscript, Dead Iota) key.
'€' 'Euro' '\u20AC' The Euro Currency Sign key: .
'DeadVoicedSound' '\u3099' The Combining Katakana-Hiragana Voiced Sound Mark (Dead Voiced Sound) key.
'DeadSemivoicedSound' '\u309A' The Combining Katakana-Hiragana Semi-Voiced Sound Mark (Dead Semivoiced Sound) key.

Appendix A: References

A.1 Normative References

[DOM3 Events]
Document Object Model Level 3 Events Specification, D. Schepers, B. Höhrmann, P. Le Hégaret, T. Pixley, Editors. World Wide Web Consortium, work in progress, September 2009. This version of the Document Object Model Level 3 Events Specification is http://www.w3.org/TR/2009/WD-DOM-Level-3-Events-20090908. The latest version of Document Object Model Level 3 Events is available at http://www.w3.org/TR/DOM-Level-3-Events.
[RFC 2119]
Key words for use in RFCs to Indicate Requirement Levels , S. Bradner, Author. Internet Engineering Task Force, March 1997. Available at http://www.ietf.org/rfc/rfc2119.txt.

Appendix B: Acknowledgements

This table was compiled using data provided by Olli Pettay (Mozilla).