Skip to content

KBD-003 Let people turn off or change a shortcut made only of character keys

Level
Rule
Verdict
Requirement
Status
proposed, version 1.0.0

Rule

When the page reacts to a shortcut made only of character keys (letters, digits, punctuation or symbols, with or without Shift), people can turn it off or change it to include a key that types nothing, such as Ctrl, Alt or Cmd, unless it works only while its own control has focus.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: A switch turns single-key shortcuts off

#482 Printer offline (Open)

The frame is a small ticket desk. It listens only while focus is inside it, so click inside the frame, then press e. The switch Single-key shortcuts is off, so the page ignores /, e and ? and says so. Turn the switch on and press them again: they work. Turn it off and they stop. Typing in Search tickets never fires anything, and Close ticket stays a button.

Do: j and k act only inside the list

j next ticketk previous ticketonly in the list

Tab into the list, then press j and k: the selection moves. The keys are handled on the list itself, so they work only while focus is in it. Click the empty part of the frame and press j: nothing moves, and the line under the frame says why. In the search field, j is just typed. No setting is needed, because no listener is page-wide.

Don't: Page-wide e, and the text-field guard is the only protection

#482 Printer offline (Open)

/ searche close? list

The frame stands in for a whole page: its listener hears every key. Click inside the frame, then press e: the ticket closes. Typing e in the search field is safe, but that guard is not a way out. The button below stands in for speech input that turns the word “edit” into key presses: the first press closes the ticket, and nothing in the page lets anyone turn that off.

Don't: Shift+D with no way out

Quarterly update (draft)

Shift+D delete draft

Click inside the frame, then press Shift+D: the draft is deleted. Shift still types a capital D, so this is a character-key shortcut, and the page offers no switch and no remap. Shift alone meets KBD-003b's default, but this rule still asks for a way out. Typing a capital D in the search field is ignored, as it should be, but that is not a way out.

Why

A shortcut on a single letter fires whenever that letter reaches the page. Some speech input programs turn spoken words into key presses, so a stray word can archive, delete or move things they never meant to touch. Keyboard users with tremors hit keys by accident, and the same happens to anyone whose focus has slipped out of a field. WCAG 2.2, 2.1.4 Character Key Shortcuts requires one of three ways out for such a shortcut: a way to turn it off, a way to remap it to include a key that types nothing, or a shortcut that acts only while its own component has focus. The criterion treats the three as equal, and so does this rule. The Working Group shows how to meet it in G217 and what fails in F99. This rule is the floor the law sets. KBD-003b goes further, as a rule the judges decide: it asks that shortcuts include a modifier key from the start, so that this rule's way out is seldom needed. Where both apply, this rule comes first. A single-key set the person turned on must be possible to turn off again, and a shortcut that adds only Shift, such as Shift+D, still needs one of the three ways out here, even though it meets KBD-003b's default.

Do

  • In a team's ticket desk, / moves focus to Search tickets, e closes the selected ticket and ? opens the list of shortcuts. Settings has a switch Single-key shortcuts that turns all three off. With it off, the page ignores those keys. This is the first way out. The switch starts off, as KBD-003b asks; this rule only needs it to exist.
  • Offer the second way instead, or as well: in Settings > Keyboard shortcuts, each shortcut can be changed to one with Ctrl, Alt or Cmd, such as Alt+E for Close ticket.
  • Or use the third way: handle j and k on the ticket list's own onKeyDown, so they move the selection only while the list or a row in it has focus. A listener on document or window is not focus-bound, even when the shortcut is meant for one panel.
  • Do not count Shift as a modifier; in these texts a modifier is Ctrl, Alt or Cmd. ? is often Shift plus /, and Shift+D still types a character, so both need a way out. A sequence such as g then t for Go to tickets is made of character keys too.
  • Make the switch and the remap screen work by keyboard, like any other control (KBD-001), and keep the choice once made, for example per account. How long the choice lasts is our own advice; the criterion does not say.
  • Keep ignoring keys typed in input, textarea and [contenteditable], so shortcuts never eat text. It is needed, but it is not one of the three ways out.
  • Shortcuts with Ctrl, Alt or Cmd are outside this rule. A command menu that opens on Cmd+K or Ctrl+K and the shadcn sidebar toggle on Cmd+B or Ctrl+B are fine as they are.
  • Keep every shortcut an extra beside a visible control, as KBD-001 says. Close ticket is still a button.

Don't

  • Bind useHotkeys("e", closeTicket) in the layout and offer no setting, so a speech user's word "edit" closes the ticket on screen.
  • Add a keydown listener on document that focuses search on /, and count the guard for text fields as the fix.
  • Use Shift+D for Delete draft on the whole page with no way out, as if Shift made it safe.
  • Hide the switch so well that only people who read the help page find it. The criterion only asks that it exists; KBD-003a is where people find shortcuts and the place to link it from.

Exceptions

  • Focus-bound keys. Keys that act only while their own control has focus meet the rule as they are: typeahead in a Select or listbox, letter keys in an open DropdownMenu, j and k on a list's own onKeyDown, a useHotkeys whose ref is attached to the list, tinykeys bound to an element rather than window or document, single-key tools on a focused drawing canvas, and / that opens a block menu inside a focused editor.
  • Keys outside the criterion. Escape, the arrow keys, Home, End, Page Up, Page Down, Tab, Enter, Space, Delete, Backspace and the function keys are not letters, digits, punctuation or symbols, and the Working Group's failure test leaves them out. Closing a panel with Escape is outside this rule.
  • Text input. Characters typed into a focused field or editor are input, not shortcuts.
  • Keys that are not the page's. The browser's and the screen reader's own keys are outside this rule.
  • Neighbouring rules. The visible control beside every shortcut is KBD-001, telling people a shortcut exists is KBD-003a, and the judges' default of a modifier key is KBD-003b.

Verdict

Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on KBD-003
SourceRoleStancePage
WCAG 2.2LawRequires2.1.4 Character Key Shortcuts
WCAG 2.2LawSupports2.1.1 Keyboard
Material DesignJudge SupportsAccessibility designing: flow
Apple Human Interface GuidelinesJudge SupportsKeyboards
Carbon Design SystemJudge No position
GOV.UK Design SystemExpert witness No position
Nielsen Norman GroupExpert witness SupportsUI Copy: UX Guidelines for Command Names and Keyboard Shortcuts, by Anna Kaley

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Keyboard: 5 rules and 0 guidelines · All rules