- Level
- A
- Since
- WCAG 2.1
2.1.4 Character Key Shortcuts
A shortcut made of a single letter, number or symbol key must be possible to turn off or remap, unless it only works while its own control has focus.
/ What it requires
Some web applications act on single keys: j and k to move through messages, e to archive, slash to jump to search, a question mark for help. That suits a fast keyboard user, but speech input turns dictated words into strings of letters, and a phrase picked up by the microphone at the wrong moment can archive, mute or move through several items in a row. People with tremor or limited dexterity hit stray keys as well. The criterion asks that such shortcuts can be switched off or changed.
It covers keyboard shortcuts implemented in the content using only letters, upper or lower case, punctuation, numbers or symbols, including sequences such as g followed by i. At least one of three conditions must hold: a mechanism turns the shortcut off, a mechanism remaps it to include a non-printable key such as Ctrl or Alt, or the shortcut belongs to a component and is active only while that component has focus. How many physical keys produce the character does not matter, so a question mark typed with Shift still counts. Typing a letter to jump within a focused listbox or menu is not affected, and neither are access keys, which browsers generally trigger with modifier keys.
/ How pages fail it
- A webmail app archives the open message on e and deletes it on # anywhere on the page, and no setting turns shortcuts off.
- A media player toggles play and mute on k and m whenever the page has focus, not only while the player does.
- Pressing s or a slash anywhere on the page moves focus to the search box, and nothing disables it.
- A help page lists the single-key shortcuts but offers no way to change them or turn them off.
- A keydown handler on document reacts to single letters whenever focus is outside a form field and never checks for a modifier key.
/ How to check it yourself
- Look in the help, settings and documentation for a list of keyboard shortcuts. Test even if there is none.
- Click a blank part of the page so that no form field has focus, then press each letter, the digits and common punctuation such as ?, / and . in turn. Ignore the browser's own features, such as find as you type.
- Note every action that fires, and whether it also fires when its related control does not have focus.
- Look for a setting that turns character shortcuts off or remaps them to include Ctrl, Alt or another modifier, and confirm that it works.
- In Chrome DevTools select the html element, open the Event Listeners pane and look for keydown, keypress and keyup handlers on document or window.
/ How to fix it
- Add a setting that turns off all single-key shortcuts and keep the choice between visits.
- Let users remap each shortcut to a combination that includes Ctrl, Alt or Meta.
- Attach the keydown listener to the component itself, such as the player or the grid, rather than to document, so the shortcut works only while that component has focus.
- Require a modifier by default, checking event.ctrlKey, event.altKey or event.metaKey in the handler before acting.
- In every case, ignore key presses whose target is an input, textarea, select or contenteditable element, so typing or dictating into a field never fires a command.
/ What our scanner checks
Nothing in our scan reports under 2.1.4. Shortcuts live in script keydown handlers, and the scan neither reads that code nor types letters into the page to see what fires. HTML_CodeSniffer posts only a reminder for this criterion, which is dropped. A manual audit presses single keys with focus outside form fields and reviews the settings for a way to turn shortcuts off or remap them.
/ Who fails it, in our own measurements
The weekly index has no figures for this criterion, because none of the checks the site scan runs can test it. A person judges it, which is what a manual audit is for.
One page per body, measured by automated checks on a weekly schedule. Any body that has fixed something since the last sweep will show it at the next one, and every entity page carries a right of reply.
/ Questions about this criterion
Do shortcuts that use Ctrl or Alt fall under 2.1.4?
No. The criterion covers shortcuts made only of printable characters: letters, numbers, punctuation and symbols. A shortcut that needs Ctrl, Alt or another non-printable key is outside it, which is why remapping a shortcut to include such a key is one of the ways to pass.
Which WCAG version added 2.1.4?
Character Key Shortcuts was added in WCAG 2.1 at level A and is part of WCAG 2.2 at the same level. An audit against WCAG 2.0 alone does not include it, while any audit against 2.1 or 2.2 at level A or AA does.
Do single-letter keys inside a focused widget count?
Not when they work only while that widget has focus. Typing a letter to jump to an option in a focused listbox, or a key that a grid handles only while it has focus, meets the third condition of the criterion. The problem is a shortcut that fires wherever focus happens to be on the page.
