1. Introduction
This document provides an overview of the various keyboard layouts and
specifies the code
values that should be
used for each of the keys. Unlike the key
values described
in [UIEvents-key], the code
values are based only on the
key’s physical location on the keyboard and do not vary based on the user’s
current locale.
This specification was formerly titled DOM Level 3 KeyboardEvent code
Values.
1.1. Stylistic Conventions
This specification uses the following conventions:
-
The key cap or label printed on a key is shown as
↓
,=
orQ
. This is used to refer to a key from the user’s perspective without regard for thekey
andcode
values in the generatedKeyboardEvent
. -
Glyphs representing character are shown as:
"𣧂"
. -
Unicode code points are shown as:
U+003D
. -
Valid key attribute values (i.e., the value of a
key
attribute) are shown as:"ArrowDown"
,"="
,"q"
or"Q"
. -
Valid key code attribute values (i.e., the value of a
code
attribute) are shown as:"ArrowDown"
,"Equal"
or"KeyQ"
.
2. Keyboard Layout
This section is non-normative.
Alphanumeric keyboards are the most common way for users to generate keyboard events. This section provides an overview of standard keyboards and their physical layouts.
2.1. Standard Keyboard Layouts
This section describes the physical layouts found on commonly available keyboards.
2.1.1. Keyboard Sections
When discussing keyboard layouts, it is convenient to divide the standard keyboard into distinct sections and to label each row.
These keyboard sections are:
-
The alphanumeric section is the main part of the keyboard and is where most of the keyboard variation occurs. When a user selects a keyboard layout, it is the keys in this sections that are most affected.
-
The control pad and arrow pad sections contain the arrow keys and other editing keys.
-
The numpad (also known as the "numeric keypad" or "number pad") contains number and math keys to make it easier to enter numeric data.
-
And finally, the function section contains miscellaneous function keys and special keys like
Escape
.
To make it easier to identify keys, the rows on the keyboard are named starting with "A" for the bottom row up to "E" for the top row. The row of keys in the function section are considered to be in row "K". These row names are consistent with those given in [ISO9995-1].
Note that many keyboards (both modern and legacy) have extra keys that do not fit neatly into the above sections. Some of these keys are covered in § 3.6 Media Keys.
2.1.2. Standard "101" Keyboard Layout
The standard "101" keyboard (commonly referred to as the "US
layout") is the only layout that has a "Backslash"
key (labeled \|
) above a single-row Enter
key. All the other
layouts omit this key and expand the Enter
key to
occupy two-rows.
Modern standard "101"-layout keyboards actually contain 104 keys: 61
keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.
The "101" name for this keyboard layout dates to the
time when this standard keyboard did in fact contain 101 keys. The
two Meta
keys (commonly given an OS-specific label), and the Menu
key were added later to bring the total to 104 keys.
2.1.3. Alternate "101" Keyboard Layout
The alternate "101" keyboard has a large Enter
key and
shrinks the Backspace
key to make room for the "IntlYen"
key (which replaces the "Backslash"
key found in the standard
101 layout). The "IntlYen"
name comes from the Japanese layout
where this is the ¥
(yen) key — in the Russian
layout shown below this key maps to a \/
.
Modern alternate "101"-layout keyboards contain 104 keys: 61 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.
2.1.4. Standard "102" Keyboard Layout
The standard "102" keyboard is common throughout Europe and adds a
key that doesn’t exist on the "101" layouts: The "IntlBackslash"
key (labelled \|
on a UK keyboard) next to the left shift
key.
A second key is also added (labelled #~
on a UK
keyboard) which is partially tucked under the Enter
key.
This key is encoded as "Backslash"
, using the same code as the \|
key found on the "101" keyboard layout.
According to [USB-HID], the US \|
and UK #~
are
actually two separate keys (named "Keyboard \ and |" and "Keyboard
Non-US # and ~"), but since these two keys never co-occur on the
same keyboard most platforms use the same scancode for both keys,
making them difficult to distinguish. It is for this reason that the
code "Backslash"
is used for both of these keys.
Modern "102"-layout keyboards contain 105 keys: 62 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.
2.1.5. Korean "103" Keyboard Layout
The Korean "103" keyboard is based on the alternate 101 layout and
adds two additional keys (one on each side of the spacebar) to
handle Korean-specific input modes. These keys are "Lang2"
("Hanja", labelled 한자
hanja)
and "Lang1"
("HangulMode", labelled 한/영
han/yeong).
Modern "103"-layout keyboards contain 106 keys: 63 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.
2.1.6. Brazilian "104" Keyboard Layout
The "104" layout used in Brazil adds 4 new keys: two keys
from the "102" layout ("Backslash"
and "IntlBackslash"
) plus
the "IntlRo"
key (next to the right shift key) and an extra key
on the numpad. This new numpad key is called "NumpadComma"
because it represents the thousands separator. On
the Brazilian key layout, this key is labelled .
and the "NumpadDecimal"
key is labelled ,
.
Modern "104"-layout keyboards contain 107 keys: 63 keys in the alphanumeric section and 44 keys in the numpad, control pad, arrow pad and function sections. Some Brazilian keyboards lack the extra numpad key and have only 106 keys.
2.1.7. Japanese "106" Keyboard Layout
The Japanese "106" keyboard layout adds 3 new keys: "IntlYen"
(labelled ¥_
), "Backslash"
(labelled ]む
)
and "IntlRo"
(labelled \ろ
).
It also shrinks the spacebar to make room for 3 input mode keys: "NonConvert"
(labelled 無変換
muhenkan), "Convert"
(labelled 変換
henkan)
and "KanaMode"
(labelled カタカナ/ひらがな/ローマ字
katakana/hiragana/romaji).
Modern "106"-layout keyboards contain 109 keys: 66 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.
2.1.8. Apple Keyboard Layout
In general, Apple keyboards follow the same layout as PC keyboards, but there are some differences as noted in the following figure.
In this figure, the green keys are those that have been moved to a new location while the blue keys indicate keys that have been added.
2.1.9. Laptop Keyboard Layouts
The limited space available on laptop keyboards often means that the physical key layout needs to be adjusted to fit all the required keys. The writing system keys in the alphanumeric section tend to remain intact, but the other keyboard sections are usually combined with other keys or removed altogether.
In this Apple laptop keyboard, the right control key has been
removed to make room for half-height arrow keys and a Fn
key
is added on the left.
PC laptop keyboards vary considerably, but this sample keyboard
demonstrates some commonly found aspects. The control pad keys are added along the right-hand side with the arrow pad keys tucked in along the bottom. The right Shift
key is
often shrunk to make room for the up arrow key and the right Meta
key is typically removed altogether.
2.1.10. Keyboard Layouts For Other Locales
Other locales are not explicitly described in this specification because they start with one of the existing layouts and adapt it by changing the keycaps and the key mappings.
Because these keyboards do not introduce new physical keys, they do not require explicit documentation.
These keyboards are typically based on the "101" (standard or alternate) or "102" layouts. For example, the common Arabic, Cyrillic, Greek, Hindi, Khmer and Thai keyboards are all based on either the "101" or "102" keyboard layouts.
2.2. Mobile Keypads
In the case where a content author wishes to rely on the mechanical
layout of a mobile keypad, this specification suggests the keyboard
configuration specified in [ISO9995-8], which defines a numeric keypad
layout and secondary assignment of Unicode characters in the range U+0061
... U+007A
("a"
- "z"
) to the number keys 2
through 9
, as a common layout appropriate to some
international uses.
This keypad layout, and in particular the distribution of letters is for English devices, and will not match the keypads or configurations of many users. Content authors cannot rely upon any particular configuration, and are expected to create content in an internationalized and localizable manner.
2.3. Media Remote Controls
Many keyboards contain special keys to control media functions. Increasingly, many media devices, especially televisions, are Web-enabled. Hybrid keyboard/remote-control devices are becoming more common. To meet the needs of these hybrid Web/media devices, this specification defines keys that are common as remote control buttons, in addition to traditional keyboard keys.
Because of the smaller form factor, keys (or buttons) on a remote
control will often be modal, with one key performing different functions
based on the context of the on-screen content. Additionally, many keys
serve as toggles, to change back and forth between two or more states
(see toggling keys). These remote control buttons typically do not have
modifier states so each button is assigned a single function (like Play
, Pause
, Up
, Menu
or Exit
).
2.4. Virtual Keyboards and Chording Keyboards
Virtual keyboards are software-based sets of keys, in a variety of different arrangements, commonly found on touch-screen devices. They are often modal, with the ability to switch between different dynamic sets of keys, such as alphabetic, numeric, or symbolic keys. Because of the lack of physical constraints, these keyboards MAY present the widest range of characters, including emoticons and other symbols. Wherever possible, however, virtual keyboards SHOULD produce the normal range of keyboard events and values, for ease of authoring and compatibility with existing content.
Chording keyboards, also known as chorded keysets or chord keyboards, are key input devices which produce values by pressing several keys in combination or sequence, normally to simulate a full range of characters or commands on a reduced set of keys, often for single-handed use. A chording keyboard MAY have additional mode keys to switch between key values, and the number and type of keys pressed to produce a key value will vary, but the final key values produced by such keyboards SHOULD match the range of key values described in this specification.
For these and other alternative modal keyboards, the key
values "Alphanumeric"
, "CapsLock"
, "NumLock"
,
and "SymbolLock"
are RECOMMENDED for the keys which switch between different modes.
3. Keyboard Event code
Value Tables
This section defines a list of values which are appropriate for use as code
values.
A key code attribute value is any of the values given in the
"KeyboardEvent.code
" column of any of the tables in this section of the
specification.
Each table in this section has a "Required" column which indicates whether or not the value is required for a conforming implementation. Entries where the "Required" column is "No" are optional and may be used by implementations to support special keyboards (such as multimedia or legacy keyboards).
Note: Some values listed in this specification as "Required" may not be available on
all platforms or devices. For example, Mac keyboards do not have an Insert
key
whereas standard PC keyboards do not have a Help
key.
For every key listed as "Required" in this specification, a conforming implementation
of the KeyboardEvent
interface MUST return the correct value as long as that key
is available on that platform.
Note: While every attempt has been made to make this list of values as complete as possible, new values will periodically need to be defined as new input devices are introduced. Rather than allowing user agents to define their own key code attribute values (which are unlikely to be consistent across multiple user agents), bugs SHOULD be filed so that this specification can be updated.
3.1. Alphanumeric Section
The alphanumeric section is the main section of the keyboard. It contains keys that fall into two general categories: writing system keys whose meaning changes based on the current keyboard layout, and functional keys which are (mostly) the same for all layouts.
3.1.1. Writing System Keys
The writing system keys are those that change
meaning (i.e., they produce different key
values) based on the current locale and keyboard layout.
This figure shows a hypothetical keyboard that combines all the writing system keys (shown in blue and green) found on the various keyboards. Blue keys are present on all standard keyboards while green keys are only available on some keyboards.
"Digit2"
and "KeyQ"
keys are writing system keys that
generate "2"
and "q"
when the US locale is
active and "é"
and "a"
when the French locale is active. The name shown on each key is the code
assigned to that key. Wherever possible, the code
names are based on the name for the US
key in that position (i.e., they are based on the US keyboard
layout), which follows the naming convention found in [USB-HID].
For keys that don’t exist on the US keyboard, names from the UK or Japanese
layouts are used instead.
Note that there are two "Backslash"
keys in this figure: a
large one at the end of Row D on the 101-key layout, and a
smaller one between "Quote"
and "Enter"
on Row C of the
102-, 104- and 106-key layouts. Only one "Backslash"
key
may be present on a keyboard layout.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Backquote"
| Yes | `~ on a US keyboard. This is the 半角/全角/漢字 (hankaku/zenkaku/kanji) key on Japanese keyboards
|
"Backslash"
| Yes | Used for both the US \| (on the 101-key layout) and also for the key located between the " and Enter keys on row C of the 102-,
104- and 106-key layouts.
Labelled #~ on a UK (102) keyboard.
|
"BracketLeft"
| Yes | [{ on a US keyboard.
|
"BracketRight"
| Yes | ]} on a US keyboard.
|
"Comma"
| Yes | ,< on a US keyboard.
|
"Digit0"
| Yes | 0) on a US keyboard.
|
"Digit1"
| Yes | 1! on a US keyboard.
|
"Digit2"
| Yes | 2@ on a US keyboard.
|
"Digit3"
| Yes | 3# on a US keyboard.
|
"Digit4"
| Yes | 4$ on a US keyboard.
|
"Digit5"
| Yes | 5% on a US keyboard.
|
"Digit6"
| Yes | 6^ on a US keyboard.
|
"Digit7"
| Yes | 7& on a US keyboard.
|
"Digit8"
| Yes | 8* on a US keyboard.
|
"Digit9"
| Yes | 9( on a US keyboard.
|
"Equal"
| Yes | =+ on a US keyboard.
|
"IntlBackslash"
| Yes | Located between the left Shift and Z keys. Labelled \| on a UK keyboard.
|
"IntlRo"
| Yes | Located between the / and right Shift keys. Labelled \ろ (ro) on a Japanese keyboard.
|
"IntlYen"
| Yes | Located between the = and Backspace keys. Labelled ¥ (yen) on a Japanese keyboard. \/ on a
Russian keyboard.
|
"KeyA"
| Yes | a on a US keyboard. Labelled q on an AZERTY (e.g., French) keyboard.
|
"KeyB"
| Yes | b on a US keyboard.
|
"KeyC"
| Yes | c on a US keyboard.
|
"KeyD"
| Yes | d on a US keyboard.
|
"KeyE"
| Yes | e on a US keyboard.
|
"KeyF"
| Yes | f on a US keyboard.
|
"KeyG"
| Yes | g on a US keyboard.
|
"KeyH"
| Yes | h on a US keyboard.
|
"KeyI"
| Yes | i on a US keyboard.
|
"KeyJ"
| Yes | j on a US keyboard.
|
"KeyK"
| Yes | k on a US keyboard.
|
"KeyL"
| Yes | l on a US keyboard.
|
"KeyM"
| Yes | m on a US keyboard.
|
"KeyN"
| Yes | n on a US keyboard.
|
"KeyO"
| Yes | o on a US keyboard.
|
"KeyP"
| Yes | p on a US keyboard.
|
"KeyQ"
| Yes | q on a US keyboard. Labelled a on an AZERTY (e.g., French) keyboard.
|
"KeyR"
| Yes | r on a US keyboard.
|
"KeyS"
| Yes | s on a US keyboard.
|
"KeyT"
| Yes | t on a US keyboard.
|
"KeyU"
| Yes | u on a US keyboard.
|
"KeyV"
| Yes | v on a US keyboard.
|
"KeyW"
| Yes | w on a US keyboard. Labelled z on an AZERTY (e.g., French) keyboard.
|
"KeyX"
| Yes | x on a US keyboard.
|
"KeyY"
| Yes | y on a US keyboard. Labelled z on a QWERTZ (e.g., German) keyboard.
|
"KeyZ"
| Yes | z on a US keyboard. Labelled w on an AZERTY (e.g., French) keyboard, and y on a
QWERTZ (e.g., German) keyboard.
|
"Minus"
| Yes | -_ on a US keyboard.
|
"Period"
| Yes | .> on a US keyboard.
|
"Quote"
| Yes | '" on a US keyboard.
|
"Semicolon"
| Yes | ;: on a US keyboard.
|
"Slash"
| Yes | /? on a US keyboard.
|
3.1.2. Functional Keys
The functional keys (not to be confused with the function keys described later) are those keys in the alphanumeric section that provide general editing
functions that are common to all locales (like Shift
, Tab
, Enter
and Backspace
). With a few
exceptions, these keys do not change meaning based on the
current keyboard layout.
The "AltRight"
key (highlighted in green) is the only functional key that does not generate the same key
value for every locale. In some locales it
produces "Alt"
while in others it produces "AltGraph"
.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"AltLeft"
| Yes | Alt , Option or ⌥ .
|
"AltRight"
| Yes | Alt , Option or ⌥ . This is labelled AltGr key on many keyboard layouts.
|
"Backspace"
| Yes | Backspace or ⌫ . Labelled Delete on Apple keyboards.
|
"CapsLock"
| Yes | CapsLock or ⇪
|
"ContextMenu"
| Yes | The application context menu key, which is typically found between the right Meta key and the right Control key.
|
"ControlLeft"
| Yes | Control or ⌃
|
"ControlRight"
| Yes | Control or ⌃
|
"Enter"
| Yes | Enter or ↵ . Labelled Return on Apple keyboards.
|
"MetaLeft"
| Yes | The Windows, ⌘ , Command or other OS symbol key.
|
"MetaRight"
| Yes | The Windows, ⌘ , Command or other OS symbol key.
|
"ShiftLeft"
| Yes | Shift or ⇧
|
"ShiftRight"
| Yes | Shift or ⇧
|
"Space"
| Yes | (space)
|
"Tab"
| Yes | Tab or ⇥
|
On some keyboards (notably Japanese and Korean) the spacebar is
reduced in size to make room for extra keys on the bottom row (Row A).
These keys typically allow the users to change the current input
mode. Note that even though some of these Japanese and Korean
keys occupy the same physical location on the keyboard, they use
different code
values.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Convert"
| Yes | Japanese: 変換 (henkan)
|
"KanaMode"
| Yes | Japanese: カタカナ/ひらがな/ローマ字 (katakana/hiragana/romaji)
|
"Lang1"
| No | Korean: HangulMode 한/영 (han/yeong)Japanese (Mac keyboard): かな (kana)
|
"Lang2"
| No | Korean: Hanja 한자 (hanja)Japanese (Mac keyboard): 英数 (eisu)
|
"Lang3"
| No | Japanese (word-processing keyboard): Katakana |
"Lang4"
| No | Japanese (word-processing keyboard): Hiragana |
"Lang5"
| No | Japanese (word-processing keyboard): Zenkaku/Hankaku |
"NonConvert"
| Yes | Japanese: 無変換 (muhenkan)
|
On Apple keyboards, some keys on the bottom row are omitted and others are arranged in a different order.
3.2. Control Pad Section
The control pad section of the keyboard is the set of (usually 6) keys
that perform navigating and editing operations, for example, Home
, PageUp
and Insert
.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Delete"
| Yes | ⌦ . The forward delete key. Note that on Apple keyboards, the key labelled Delete on the main part of
the keyboard should be encoded as "Backspace" .
|
"End"
| Yes | End or ↘
|
"Help"
| Yes | Help . Not present on standard PC keyboards.
|
"Home"
| Yes | Home or ↖
|
"Insert"
| Yes | Insert or Ins . Not present on Apple keyboards.
|
"PageDown"
| Yes | Page Down , PgDn or ⇟
|
"PageUp"
| Yes | Page Up , PgUp or ⇞
|
The code
for the Fn
key (found on some
Apple keyboards) is defined below in the function section.
3.3. Arrow Pad Section
The arrow pad contains the 4 arrow keys. The keys are commonly arranged in an "upside-down T" configuration.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"ArrowDown"
| Yes | ↓
|
"ArrowLeft"
| Yes | ←
|
"ArrowRight"
| Yes | →
|
"ArrowUp"
| Yes | ↑
|
3.4. Numpad Section
The numpad section is the set of keys on the keyboard arranged in
a grid like a calculator or mobile phone. This section contains numeric and
mathematical operator keys. Often this section will contain a NumLock
key which causes the keys to switch between the standard numeric functions
and mimicking the keys of the control pad and arrow pad.
Laptop computers and compact keyboards will commonly omit these
keys to save space.
A keypad is an alternate term for numpad.
The code
values in this section should also be
used for phone keypads and remote control devices that
arrange number keys in a grid.
The standard numpad is sometimes extended with additional keys for
parentheses, operators, hexadecimal symbols, or calculator functions
(like Backspace
). Some of the commonly added keys are listed
in the table below.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"NumLock"
| Yes | On the Mac, the "NumLock" code should be used for the numpad Clear key.
|
"Numpad0"
| Yes | 0 Ins on a keyboard0 on a phone or remote control
|
"Numpad1"
| Yes | 1 End on a keyboard1 or 1 QZ on a phone or remote control
|
"Numpad2"
| Yes | 2 ↓ on a keyboard2 ABC on a phone or remote control
|
"Numpad3"
| Yes | 3 PgDn on a keyboard3 DEF on a phone or remote control
|
"Numpad4"
| Yes | 4 ← on a keyboard4 GHI on a phone or remote control
|
"Numpad5"
| Yes | 5 on a keyboard5 JKL on a phone or remote control
|
"Numpad6"
| Yes | 6 → on a keyboard6 MNO on a phone or remote control
|
"Numpad7"
| Yes | 7 Home on a keyboard7 PQRS or 7 PRS on a phone or remote control
|
"Numpad8"
| Yes | 8 ↑ on a keyboard8 TUV on a phone or remote control
|
"Numpad9"
| Yes | 9 PgUp on a keyboard9 WXYZ or 9 WXY on a phone or remote control
|
"NumpadAdd"
| Yes | +
|
"NumpadBackspace"
| No | Found on the Microsoft Natural Keyboard. |
"NumpadClear"
| No | C or AC (All Clear). Also for use with numpads that have a Clear key that is separate from the NumLock key. On the Mac, the numpad Clear key should always
be encoded as "NumLock" .
|
"NumpadClearEntry"
| No | CE (Clear Entry)
|
"NumpadComma"
| No | , (thousands separator). For locales where the thousands separator is a "." (e.g., Brazil), this key may generate a . .
|
"NumpadDecimal"
| Yes | . Del . For locales where the decimal separator is "," (e.g., Brazil), this key may generate a , .
|
"NumpadDivide"
| Yes | /
|
"NumpadEnter"
| Yes | |
"NumpadEqual"
| No | =
|
"NumpadHash"
| No | # on a phone or remote control device. This key is typically found below the 9 key and to the right of the 0 key.
|
"NumpadMemoryAdd"
| No | M+ Add current entry to the value stored in memory.
|
"NumpadMemoryClear"
| No | MC Clear the value stored in memory.
|
"NumpadMemoryRecall"
| No | MR Replace the current entry with the value stored in memory.
|
"NumpadMemoryStore"
| No | MS Replace the value stored in memory with the current entry.
|
"NumpadMemorySubtract"
| No | M- Subtract current entry from the value stored in memory.
|
"NumpadMultiply"
| Yes | * on a keyboard. For use with numpads that provide mathematical operations (+ , - , * and / ).Use "NumpadStar" for the * key on phones and remote controls.
|
"NumpadParenLeft"
| No | ( Found on the Microsoft Natural Keyboard.
|
"NumpadParenRight"
| No | ) Found on the Microsoft Natural Keyboard.
|
"NumpadStar"
| No | * on a phone or remote control device. This key is typically found below the 7 key and to the left of
the 0 key.Use "NumpadMultiply" for the * key on
numeric keypads.
|
"NumpadSubtract"
| Yes | -
|
For numpads that provide keys not listed here, a code
value string should be created by starting
with "Numpad" and appending an appropriate description of the key.
3.5. Function Section
The function section runs along the top of the keyboard (above
the alphanumeric section) and
contains the function keys and a few additional special keys
(for example, Esc
and Print Screen
).
A function key is any of the keys labelled F1
... F12
that an application or operating system can associate with a custom function
or action.
On some keyboards (especially those found on laptops or other
portable computers), the function keys (F1
... F12
) are defined to have other primary functions (like
controlling display brightness or audio volume) and require that a
separate Fn
key be pressed to make them act as function
keys. Unfortunately, the primary functions assigned to these keys
varies widely from one manufacturer to the next. Because of this,
the code
is always set to the function key name.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Escape"
| Yes | Esc or ⎋
|
"F1"
| Yes | F1
|
"F2"
| Yes | F2
|
"F3"
| Yes | F3
|
"F4"
| Yes | F4
|
"F5"
| Yes | F5
|
"F6"
| Yes | F6
|
"F7"
| Yes | F7
|
"F8"
| Yes | F8
|
"F9"
| Yes | F9
|
"F10"
| Yes | F10
|
"F11"
| Yes | F11
|
"F12"
| Yes | F12
|
"Fn"
| No | Fn This is typically a hardware key that does not generate a separate code. Most keyboards do not place this key in the function section, but it is
included here to keep it with related keys.
|
"FnLock"
| No | FLock or FnLock . Function Lock key. Found on the Microsoft Natural Keyboard.
|
"PrintScreen"
| Yes | PrtScr SysRq or Print Screen
|
"ScrollLock"
| Yes | Scroll Lock
|
"Pause"
| Yes | Pause Break
|
For keyboards that provide more than 12 function keys, the code
value follows the pattern shown above with
"F" followed by the function key number - "F13"
, "F14"
, "F15"
, and so on.
Apple keyboards may have Eject
or Power
keys in the function section. The code
values for these
keys are defined in § 3.6 Media Keys.
3.6. Media Keys
Media keys are extra keys added to a keyboard that provide media related functionality like play, pause or volume control. These keys do not have a standard location on the keyboard so keyboards from different manufacturers are likely to have a different arrangement of keys or a completely different sets of keys.
Media keys are often distinct from normal typing keys in appearance and may be recessed in the keyboard.
On laptop keyboards, these keys are often merged with the function keys, with the media key interpretation being
the primary function of the key and the function key interpretation requiring the Fn
key to be pressed at the
same time. In this configuration the code
should
be set to match the function key ("F1"
... "F12"
).
When the keys are merged in this fashion, the code
values are taken from the function key value because the media key value is not consistent across keyboards.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"BrowserBack"
| No | Some laptops place this key to the left of the ↑ key.
|
"BrowserFavorites"
| No | |
"BrowserForward"
| No | Some laptops place this key to the right of the ↑ key.
|
"BrowserHome"
| No | |
"BrowserRefresh"
| No | |
"BrowserSearch"
| No | |
"BrowserStop"
| No | |
"Eject"
| No | Eject or ⏏ . This key is placed in the function section on some Apple keyboards.
|
"LaunchApp1"
| No | Sometimes labelled My Computer on the keyboard
|
"LaunchApp2"
| No | Sometimes labelled Calculator on the keyboard
|
"LaunchMail"
| No | |
"MediaPlayPause"
| No | |
"MediaSelect"
| No | |
"MediaStop"
| No | |
"MediaTrackNext"
| No | |
"MediaTrackPrevious"
| No | |
"Power"
| No | This key is placed in the function section on some Apple keyboards, replacing the Eject key.
|
"Sleep"
| No | |
"AudioVolumeDown"
| No | |
"AudioVolumeMute"
| No | |
"AudioVolumeUp"
| No | |
"WakeUp"
| No |
3.7. Legacy, Non-Standard and Special Keys
These keys are not found on modern standard keyboards. They are listed here for reference purposes.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Hyper"
| No | |
"Super"
| No | |
"Turbo"
| No |
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Abort"
| No | |
"Resume"
| No | |
"Suspend"
| No |
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Again"
| No | Found on Sun’s USB keyboard. |
"Copy"
| No | Found on Sun’s USB keyboard. |
"Cut"
| No | Found on Sun’s USB keyboard. |
"Find"
| No | Found on Sun’s USB keyboard. |
"Open"
| No | Found on Sun’s USB keyboard. |
"Paste"
| No | Found on Sun’s USB keyboard. |
"Props"
| No | Found on Sun’s USB keyboard. |
"Select"
| No | Found on Sun’s USB keyboard. |
"Undo"
| No | Found on Sun’s USB keyboard. |
The following keys may be found on non-standard international keyboards.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Hiragana"
| No | Use for dedicated ひらがな key found on some Japanese word processing keyboards.
|
"Katakana"
| No | Use for dedicated カタカナ key found on some Japanese word processing keyboards.
|
And finally, the following code
value should only
be used when the corresponding key does not correspond to any of the code
values given elsewhere in this specification.
This value is appropriate for use with virtual keyboards that do not
have their keys arranged in a way that corresponds to those on a
physical keyboard.
KeyboardEvent code
| Required | Notes (Non-normative) |
---|---|---|
"Unidentified"
| Yes | This value code should be used when no other value given in this specification is appropriate. |
Conforming implementations MUST only use "Unidentified"
as a key code
when there is no way for the implementation to determine the key code.
Exposing only this value MUST NOT indicate a conforming implementation.
4. Accessibility
This specification simply defines a set of values that are valid for use in the code
attribute. Thus, it does not introduce any features that have
accessibility concerns.
The FAST checklist has been completed and nothing is applicable to this specification.
A note related to the FAST checklist item: "If technology provides internationalization support".
This specification inherently defines code
values for keyboards and provides
human-readable names (like "ShiftLeft", "ControlRight", "AltGr" or "KeyQ").
These special key values are defined as human-readable strings so that code to detect special keys can be easier to understand. While these values are not intended to be exposed directly to users, there is nothing preventing that. Apps that choose to expose these values would need to determine whether or not it is appropriate to translate these strings for presentation (e.g.: presenting "Backspace" as "Suppr. arrière" for French users).
5. I18n
The short I18n checklist has been completed and the following item requires a comment:
-
"describes a format or data that is likely to need localisation": This specification defines values that are not intended for display to the user, although there is nothing preventing sites from exposing these values.
6. Security Considerations
The Security and Privacy Self-Review Questionairre has been completed with the following notes:
-
2.1 What information might this feature expose to Web sites or other parties, and for what purposes is that exposure necessary?: This spec defines a set of valid values for the
code
attribute of the various key events. This is necessary to provides a platform-independent way of identifying which physical key (by location) has been pressed (for example, WASD keys in games). -
2.17 How does your feature handle non-"fully active" documents?: This attribute is only associated with key events, and events are not sent if the document is not fully active.
Security concerns associated with the code
attribute are addressed in the [UIEvents] specification.
7. Privacy Considerations
The Security and Privacy Self-Review Questionairre has been completed with the following notes:
-
2.6 Do the features in your specification expose information about the underlying platform to origins?: The
code
attribute contains a platform-independent "scancode" value for the key pressed by the user. There are a few special `code` values that can be used to identify particular keyboards. For example, `IntlBackslash`, `IntlRo` and `IntlYen`. The user would have to type these keys for the information to be exposed. -
3.5 Legitimate Misuse: A site could capture all keypresses and build a map of the values generated by the keyboard. If the user types enough values (and doesn’t change keyboard), then the site could try to match those values against a database of known keyboard layouts to guess the user’s current keyboard layout. However, that’s a concern for the
key
attribute itself (defined in the [UIEvents] specification) rather than something specific to the values defined in this document
Privacy concerns associated with the code
attribute are addressed in the [UIEvents] specification.
8. Acknowledgements
Considerable thanks are due to the following participants of the WebApps Working Group for providing substantial material contributions in the process of developing this specification.
Gary Kacmarcik (Google), Masayuki Nakano (Mozilla)