Operable · 2.1 Keyboard Accessible

Character Key Shortcuts WCAG 2.1.4 · Level A

If the content implements a keyboard shortcut that uses only letter, punctuation, number or symbol keys, users must be able to turn it off, remap it to include a non-printable key such as Ctrl or Alt, or it must be active only when its component has focus.

Level
A
Since
WCAG 2.1
Principle
Operable
Guideline
2.1 Keyboard Accessible

Live demo

Speak into an inbox with letter shortcuts

The same task, done two ways: switch between the version that passes and the one that fails, or put them side by side. Everything in the box is live, so try it with a keyboard, a pointer or a screen reader.

Press Simulate speech input in each version and watch the messages. In Passes, tick Turn off single-key shortcuts and try again.

Live example

Passes

Inbox

Shortcuts: A archives, D deletes and R replies.

  • Your train ticket to Leeds is ready
  • Your March bank statement is available
  • Order 4821 has been dispatched

What happened

    Why it passes

    The shortcuts are there for people who want them, and one tick turns them off, so the letters in spoken words stay as words.

    Why it fails

    Every A, D or R in a spoken phrase is taken as a command, so messages get archived or deleted by accident and nothing turns the shortcuts off.

    Examples

    Code that fails, and the fix

    Four examples, each one running: the usual ways this criterion fails, and code that passes. Listen to them, measure them, or copy the code.

    01What changes 5 lines

    Fails

    Letter shortcuts that fire anywhere

    Live preview

    JavaScript
    document.addEventListener("keydown", (event) => {  if (event.key === "a") archiveSelectedMessage();  if (event.key === "d") deleteSelectedMessage();  if (event.key === "r") replyToSelectedMessage();});

    Single letters act anywhere on the page and cannot be turned off. A speech input user who says a word with a d in it can delete a message.

    Passes

    A setting that turns the shortcuts off

    Live preview

    JavaScript
    // <input type="checkbox" id="letter-shortcuts" checked>// <label for="letter-shortcuts">Single-key shortcuts</label>const shortcutsOn = document.getElementById("letter-shortcuts");document.addEventListener("keydown", (event) => {  if (!shortcutsOn.checked) return;  if (event.target.closest("input, textarea, [contenteditable]")) return;  if (event.key === "a") archiveSelectedMessage();  if (event.key === "d") deleteSelectedMessage();  if (event.key === "r") replyToSelectedMessage();});

    A setting in the page turns the letter shortcuts off, which the criterion accepts. They also stay quiet while the user is typing in a field.

    02What changes 4 lines

    Fails

    Video keys that work from anywhere

    Live preview

    JavaScript
    // Anywhere on the page: K plays or pauses, L skips forward 10 secondsdocument.addEventListener("keydown", (event) => {  if (event.key === "k") video.paused ? video.play() : video.pause();  if (event.key === "l") video.currentTime += 10;});

    The keys work wherever focus is, so a speech input user dictating a comment below the video can pause it or skip ahead by accident.

    Passes

    Video keys only while the player has focus

    Live preview

    JavaScript
    // <div id="player" role="region" aria-label="Video player" tabindex="0">//   wraps the video and its controlsconst player = document.getElementById("player");player.addEventListener("keydown", (event) => {  if (event.key === "k") video.paused ? video.play() : video.pause();  if (event.key === "l") video.currentTime += 10;});

    The keys are handled only while focus is inside the player, which the criterion allows, so typing or speaking elsewhere on the page cannot trigger them.

    Why it matters

    Who it helps

    Speech input users can set off single-key shortcuts by accident when their spoken words arrive as keystrokes, and people with tremor or imprecise typing can trigger them by mistake. Shortcuts that can be disabled or need a modifier prevent unintended actions.

    W3C: Understanding 2.1.4
    • Level A

      Level A is the minimum: failing it can shut some people out completely.

    • In WCAG versions

      Added in WCAG 2.1 in June 2018, and kept in 2.2.

      No WCAG 1.0 checkpoint maps to it.

    • Where it is required

      Required where the law names WCAG 2.1 or later at this level: the United States, Canada, the European Union, the United Kingdom, France, Germany, Italy, Spain, the Netherlands, Ireland, Norway, Switzerland, India, Australia and New Zealand.

    How to test

    Checking it

    A few concrete steps. Automated tools find some failures; most need a person.

    1. Check the documentation, then press single printable keys with focus outside any text field to find shortcuts that act without a modifier key.
    2. For each one found, confirm it can be turned off or remapped to include a modifier such as Ctrl or Alt, or that it works only while its component has focus.

    Common failures

    Where it breaks

    • A web mail app archives or deletes a message when a single letter key is pressed, with no setting to turn the shortcut off or remap it.
    • A media player responds to single letter keys anywhere on the page, so a speech input user's spoken words can pause or skip the video.