Skip to content

KBD-003b Build a shortcut on a modifier key by default

Level
Rule
Verdict
Unanimous (2 of 2)
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

Click inside the frame, then press Ctrl+K (or Cmd+K): search opens. Press Alt+Shift+N: a new invoice starts. Both are matched for both platforms, and the second on the physical key, so Option works on a Mac. Press a plain n: nothing happens, because a single key is not a shortcut here. The buttons do the same things.

Do: Single keys only after the person turns them on

Invoices started here: 0

/ searchn new invoice

Click inside the frame, then press n: it is ignored, because the switch Use single-key shortcuts starts off. Turn the switch on and press n or /: they work. The same switch turns them off again. Typing in the search field never fires anything.

Don't: Single keys on from the start, with a switch

Invoices started here: 0

/ searchn new invoice

The switch exists, but it starts on. Click inside the frame, then press n: a new invoice starts before anyone chose anything. Turning the switch off works, so this meets KBD-003, but the default is a single key, which KBD-003b does not accept.

Do: Shift+N with a switch to turn it off

Invoices started here: 0

Shift+N new invoice

Click inside the frame, then press Shift+N: a new invoice starts. Shift alone meets this rule's default, but Shift+N still types a capital N, so KBD-003 asks for a way out. Here it is the switch Use Shift shortcuts: turn it off and Shift+N is ignored. Without the switch the page would break KBD-003, though not this rule. Typing a capital N in the search field never fires anything.

Don't: Only Cmd is bound

Invoices started here: 0

Cmd+K search

Click inside the frame, then press Cmd+K: search opens. Press Ctrl+K: the page does nothing (your browser may use the keys itself), and the line under the frame says so. On Windows and Linux there is no Cmd key, so those people have no shortcut at all.

Don't: The page takes Ctrl+F

Invoices started here: 0

Ctrl/Cmd+F filter invoices

Turn on Let the page take Ctrl+F, click inside the frame, then press Ctrl+F (or Cmd+F): the page stops the browser's find, so people lose find in page while focus is here. It starts off, so the keys work as usual until you turn it on, and it turns off again when focus leaves the frame. The keys the browser owns are left alone, and a page that needs its own filter gives it another key.

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 and e.key is no longer n.
  • Offer single keys as a choice: Settings > Keyboard shortcuts has a switch Use single-key shortcuts, off at first. Once turned on, n starts a new invoice and / focuses search. The same switch turns them off again, which is what KBD-003 needs.
  • Bind both platforms. Libraries' mod and $mod mean Cmd on a Mac and Ctrl elsewhere; e.metaKey alone 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 Select or listbox, letter keys in an open DropdownMenu, j and k on a list's own onKeyDown or on a useHotkeys whose ref is attached to the list, tinykeys bound to an element rather than window or document, 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

Stances on KBD-003b
SourceRoleStancePage
WCAG 2.2LawSupports2.1.4 Character Key Shortcuts
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 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