KBD-003b Build a shortcut on a modifier key by default
- Level
- Rule
- Verdict
- Unanimous (2 of 2)
- Area
- Keyboard
- Status
- proposed, version 1.0.0
Rule
A keyboard shortcut the product adds includes a modifier key (Ctrl, Alt or Cmd) or Shift by default. A single key, such as n or /, works as a shortcut only after the person turns such shortcuts on, or 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 modifier key from the start
Invoices started here: 0
Ctrl/Cmd+K searchAlt+Shift+N new invoice
Do: Single keys only after the person turns them on
Invoices started here: 0
/ searchn new invoice
Don't: Single keys on from the start, with a switch
Invoices started here: 0
/ searchn new invoice
Do: Shift+N with a switch to turn it off
Invoices started here: 0
Shift+N new invoice
Don't: Only Cmd is bound
Invoices started here: 0
Cmd+K search
Don't: The page takes Ctrl+F
Invoices started here: 0
Ctrl/Cmd+F filter invoices
Why
A key that types a character also arrives when someone types in the wrong place, brushes the keyboard or speaks to some speech input programs, which turn words into key presses. A shortcut that needs Ctrl, Alt or Cmd cannot fire that way, so it is safe from the start, without asking anyone to find a setting first. WCAG 2.2, 2.1.4 Character Key Shortcuts asks less: it allows a single-key shortcut on from the start, if it can be turned off, changed or is bound to focus. That floor is KBD-003, a Requirement. This rule raises it, on the judges' verdict, not the law's. The two never pull apart: a product that follows this rule follows KBD-003 too, provided the single-key shortcuts a person turned on can be turned off again, as KBD-003 asks. A product that meets only KBD-003, with single keys on by default and a switch to turn them off, meets the law but not this rule. Shift is not a modifier in these texts. Shift alone meets this rule's default, but Shift+N still types a character, so KBD-003 asks for a way out: a switch, a remap or focus binding. Where both apply, KBD-003 comes first.
Do
- In an invoicing app, Cmd+K or Ctrl+K opens the command menu, bound with
useHotkeys("mod+k", …)or(e.metaKey || e.ctrlKey) && e.key === "k". The button Search in the header opens it too (KBD-001). - Give New invoice Alt+Shift+N beside its button. Match Alt and Option shortcuts on
e.code(KeyN), because Option plus a letter types a special character on a Mac ande.keyis no longern. - Offer single keys as a choice: Settings > Keyboard shortcuts has a switch Use single-key shortcuts, off at first. Once turned on,
nstarts a new invoice and/focuses search. The same switch turns them off again, which is what KBD-003 needs. - Bind both platforms. Libraries'
modand$modmean Cmd on a Mac and Ctrl elsewhere;e.metaKeyalone does nothing on Windows. - Our own advice: leave the browser's own combinations alone, such as Ctrl or Cmd with F, L, T, W or P, and Ctrl+Tab. A page that saves its own documents may use Ctrl or Cmd+S for Save, since that keeps its usual meaning.
- Our own choice: prefer Ctrl, Alt or Cmd to Shift alone, so the shortcut needs none of KBD-003's ways out.
- Give a Shift-only shortcut, such as Shift+N, one of KBD-003's ways out.
- Show the keys you chose, as KBD-003a asks.
Don't
- Ship
useHotkeys("n", newInvoice)on from the start, even with a switch to turn it off. It meets KBD-003 but not this rule. - Bind only
e.metaKey, so the shortcut does nothing for people on Windows. - Call
preventDefault()on Ctrl+F, so people lose find in page.
Exceptions
- Keys bound to focus. Typeahead in a
Selector listbox, letter keys in an openDropdownMenu,jandkon a list's ownonKeyDownor on auseHotkeyswhose ref is attached to the list,tinykeysbound to an element rather thanwindowordocument, and single-key tools on a drawing canvas that has focus are not page-wide shortcuts. They are outside this rule, as they are outside KBD-003's demand for a way out. - The standard keys of a control. Escape in a dialog or an open overlay, the arrow keys in a menu and Enter in a form come with the control and are not shortcuts the product adds.
- Neighbouring rules. The legal floor for character keys is KBD-003, the visible control beside every shortcut is KBD-001, and making shortcuts findable is KBD-003a.
Verdict
Unanimous (2 of 2). Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 2.1.4 Character Key Shortcuts |
| Material Design | Judge | Supports | Accessibility designing: flow |
| Apple Human Interface Guidelines | Judge | Supports | Keyboards |
| Carbon Design System | Judge | No position | |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert witness | No position |
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
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.