UX Design

Keyboard Accessibility: WCAG Criteria, Keys and Test Steps

By EZUD Published · Updated

The core of keyboard accessibility is six WCAG 2.2 success criteria: 2.1.1 Keyboard (Level A), 2.1.2 No Keyboard Trap (A), 2.4.1 Bypass Blocks (A), 2.4.3 Focus Order (A), 2.4.7 Focus Visible (AA) and 2.4.11 Focus Not Obscured (Minimum) (AA). Together they require that everything can be operated from a keyboard, that focus never gets stuck, that repeated blocks can be skipped, that focus moves in a meaningful order, and that the focused control is both visible and not entirely hidden behind author-created content. The WAI-ARIA Authoring Practices Guide (APG) then supplies the key conventions for custom widgets.

The six criteria at a glance

SCLevelNormative requirement (short)Typical failure
2.1.1 KeyboardAAll functionality is operable through a keyboard interface, without specific keystroke timingsA control that responds only to mouse or touch events (failure F54)
2.1.2 No Keyboard TrapAIf focus can move into a component, it can move out using only the keyboardAn embedded widget that swallows Tab
2.4.1 Bypass BlocksAA mechanism bypasses blocks repeated across pagesNo skip link, headings or landmarks
2.4.3 Focus OrderAFocusable components receive focus in an order that preserves meaning and operabilityA dialog not adjacent to its trigger in the focus sequence (F85)
2.4.7 Focus VisibleAAA keyboard-operable interface has a mode in which the focus indicator is visibleoutline: none with no replacement (F78)
2.4.11 Focus Not Obscured (Minimum)AAA focused component is not entirely hidden by author-created contentA sticky footer covering the focused field (F110)

WCAG 2.2 became a W3C Recommendation on 5 October 2023; the current edition is dated 12 December 2024. Of its nine new criteria, 2.4.11 is the only Level A or AA one that changes keyboard testing; the other five criteria in the table were already in earlier versions. Other criteria touch keyboard use too, such as 2.1.4 Character Key Shortcuts (A) and 3.2.1 On Focus (A), but these six carry the core requirements. For the full 2.2 list and conformance levels, see WCAG 2.2 explained.

What each criterion demands

2.1.1 Keyboard: everything works, with no timing tricks

The criterion says all functionality must be operable through a keyboard interface “without requiring specific timings for individual keystrokes.” The Understanding document treats rapid repeated keystrokes or long key holds as specific timings. The one exception covers input whose underlying function depends on the path of the movement, such as freehand drawing. Drawing a straight line, resizing a window or dragging an object to a destination do not qualify, so a drag-and-drop list needs a keyboard route to reorder items.

The W3C also states that MouseKeys does not satisfy the criterion, because it emulates a mouse instead of giving the page keyboard operation. The named failures are F54 (only pointer-specific event handlers, including gestures), F42 (emulating links in a way that breaks 1.3.1, 2.1.1, 2.1.3 or 4.1.2) and F55 (script that removes focus as soon as an element receives it).

Native controls are a sufficient technique (H91, Using HTML form controls and links). A real button, a href, input, select or textarea is focusable and operable without author code:

<button type="button" aria-expanded="false" aria-controls="delivery">
  Show delivery details
</button>
<div id="delivery" hidden>...</div>

A div with role="button" only changes what assistive technology announces. The author must add focusability and key handling too, which is why the Understanding document lists ARIA on repurposed elements as an advisory technique, paired with SCR29 for keyboard-accessible actions on static HTML elements.

2.1.2 No Keyboard Trap: temporary containment is allowed

If focus can be moved into a component using the keyboard, it must be movable out using only the keyboard. If leaving requires more than unmodified arrow or Tab keys or another standard exit method, the user must be told how. The W3C notes that focus may be restricted temporarily, as in a modal dialog or popover, provided users can find out how to leave. It does not define “standard exit methods”; Escape is the common one on a physical keyboard, but platform conventions differ.

Because a trap can disable the whole page, the criterion applies even to content that is not used to claim conformance elsewhere (Conformance Requirement 5). The W3C names content rendered by plug-ins or embedded applications, and custom widgets built without keyboard users in mind, as the common source.

The sufficient techniques include a skip link at the top of each page (G1), ARIA landmarks (ARIA11) and headings at the start of each section (H69). The criterion targets repeated blocks such as navigation, header content and advertising, not single repeated links or words. A skip link is the most reliable test target because it is one Tab press away:

<body>
  <a href="#main" class="skip-link">Skip to main content</a>
  <header>...</header>
  <main id="main" tabindex="-1">...</main>
</body>

The tabindex="-1" on the target lets script place focus there without adding another Tab stop; the APG describes it as “not included in the tab sequence but is focusable with element.focus().” A visually hidden skip link must become visible when focused, or it fails 2.4.7.

2.4.3 Focus Order: meaning and operability, not visual symmetry

The criterion applies “if a web page can be navigated sequentially and the navigation sequences affect meaning or operation.” The W3C states that more than one order can satisfy it and that focus order need not match the visual layout, as long as meaning and operability are preserved. Failure F44 covers using tabindex to create an order that breaks this; F85 covers a dialog or menu that is not adjacent to its trigger in the sequence.

On positive values, the APG is blunt about tabindex 1 to 32767: “Authors are strongly advised NOT to use these values.” Use tabindex="0" to add an element to the sequence by its DOM position and tabindex="-1" for programmatic focus only. Check the case where CSS (flex order, grid placement, position) rearranges what is seen, because focus follows the DOM.

2.4.7 Focus Visible and the 2.4.13 reference point

2.4.7 requires “a mode of operation where the keyboard focus indicator is visible,” and says the indicator must not be time limited. Failure F78 is styling outlines or borders so the indicator disappears. The APG advises relying on browser defaults, and requires that the selected state be visually distinct from the focus indicator.

MDN explains that :focus-visible matches when an element has focus and the browser decides focus should be evident: a keyboard Tab to a button shows the ring, a mouse click on a button generally does not, and a text box shows focus. This allows a custom style that appears for keyboard use:

:focus-visible {
  outline: 3px solid #1a4fd6;
  outline-offset: 2px;
}

For a stricter benchmark, 2.4.13 Focus Appearance (AAA, new in WCAG 2.2) asks that the indicator area be at least as large as a 2 CSS pixel thick perimeter of the unfocused component and have 3:1 contrast between the focused and unfocused pixels. It is not required at AA, but it is a clear target for a design system. Contrast of the indicator against the page is covered in color contrast checking.

2.4.11 Focus Not Obscured (Minimum): the new test for sticky UI

The text: “When a user interface component receives keyboard focus, the component is not entirely hidden due to author-created content.” Two notes apply. For configurable interfaces where users can move content, only the initial positions are tested. And if opened content covers the focused component but the user can reveal it without moving focus, it is not treated as hidden.

The W3C examples show what passes: a sticky footer that does not fully hide focused items because scroll padding keeps them in view; a modal cookie dialog that takes focus and stays mostly on screen; a sticky-header notification that receives focus and closes when focus leaves. Failure F110 is a sticky header or footer that completely hides a focused element. Partial overlap passes at AA; the AAA sibling, 2.4.12 Focus Not Obscured (Enhanced), is the one that wants none of the component hidden.

The W3C’s sufficient technique is CSS: C43, Using CSS scroll-padding to un-obscure content. MDN documents scroll-padding as a way to inset the scrollport “to make room for objects that might obscure the content, such as fixed-positioned toolbars or sidebars”:

html { scroll-padding-top: 4rem; }  /* at least the sticky header height */

MDN’s example is for in-page anchor navigation, so test Tab movement in both directions separately rather than assuming the property covers it.

Keys per component

The APG convention is that Tab and Shift+Tab move focus between components, and arrow keys move focus within a composite widget. Two techniques implement the latter: a roving tabindex (the active child has tabindex="0", the rest -1, updated on each arrow press) or aria-activedescendant (the container keeps DOM focus and points at the active child). The table lists the keys the relevant APG pattern specifies.

ComponentKeys and expected result (APG pattern)
Link and buttonReachable by Tab; links are activated by Enter, buttons by Enter and Space (APG Link and Button patterns)
Accordion headerEnter or Space expands or collapses the panel; Tab and Shift+Tab move through every focusable element, including all headers
Tab listTab lands on the active tab; Left and Right Arrow move between tabs (Up and Down in a vertical list), wrapping; Home and End are optional; a second Tab press leaves the list, usually to the tab panel; Space or Enter activates a tab unless activation happens on focus
Menu buttonEnter or Space opens the menu and focuses the first item; optional Down Arrow opens and focuses the first item, Up Arrow the last
Open menu or menubarArrow keys move among items; Enter activates, or opens a submenu; Escape closes the menu and returns focus to the opener; Tab closes all menus and moves focus out; optional typed character jumps to the next item starting with it
Radio groupTab enters on the checked radio (or the first if none); arrows move focus, uncheck the old and check the new, wrapping; Space checks the focused one; Tab leaves the group
SliderRight or Up Arrow raises one step, Left or Down lowers one; Home sets the first allowed value in the range, End the last; Page Up and Page Down are optional larger steps
ComboboxDown Arrow moves into the popup; Escape closes the popup; Enter accepts the highlighted suggestion; optional Alt+Down Arrow opens the popup without moving focus; with a listbox popup, DOM focus stays on the combobox and the active option is exposed with aria-activedescendant
Modal dialogFocus moves into the dialog on open; Tab and Shift+Tab cycle and wrap inside it; Escape closes; focus returns to the opener

Two points from these patterns catch teams out. First, a tab list is one Tab stop, not one per tab, so a test that expects Tab to visit each tab is testing the wrong pattern. Second, a custom widget that handles keys must not swallow keys users need elsewhere; a document-level shortcut handler that intercepts a letter key can break typing in a text field.

For how ARIA roles relate to this behavior, and where speech output needs its own check, see screen reader compatibility.

The APG dialog pattern is specific about focus placement. On open, focus goes to an element inside, and the best target depends on content: for lists, tables or multiple paragraphs, put tabindex="-1" on a static element at the start and focus that; for long content, focus a static element such as the title so the beginning does not scroll away; for an irreversible final step such as deleting data, consider the least destructive action; for an informational dialog, consider the most-used button. On close, focus returns to the opener, unless it no longer exists or the workflow points elsewhere (for example, to the first cell of a newly added row after an “Add Rows” dialog).

The native dialog element handles much of this. According to MDN, a dialog opened with showModal() makes the rest of the page inert, has implicit aria-modal="true", closes on Esc by default, and sets focus on the first nested focusable element, which the autofocus attribute can override. MDN does not state where focus goes after closing, so verify that in the browsers the audience uses and restore it in script if needed.

<dialog id="confirm" aria-labelledby="confirm-title">
  <h2 id="confirm-title" tabindex="-1">Delete this address?</h2>
  <button type="button" id="cancel" autofocus>Keep address</button>
  <button type="button" id="delete">Delete</button>
</dialog>

This satisfies 2.1.2: containment is allowed because the dialog offers Escape and a visible cancel button.

A repeatable test procedure

The procedure checks one task end to end. Run it per template and per shared component; the six criteria then become observations.

StepActionCriterion checkedPass condition
1Load the page, press Tab once2.4.1, 2.4.7A skip link appears visibly, or a landmark or heading route exists; focus indicator is visible
2Activate the skip link, press Tab2.4.1, 2.4.3Focus lands on the first interactive element after the target, not back in the header
3Tab through the entire page, then Shift+Tab back2.4.3, 2.4.7Order follows the task; no tab stop is invisible; no stop is skipped; the reverse path matches
4Operate every control with keys only (links, buttons, fields, menus, custom widgets)2.1.1Each function completes without a mouse; no step requires rapid keystrokes or holds
5Enter each embedded or modal component and leave it2.1.2Focus leaves using Tab, Shift+Tab, arrows or an advertised key such as Escape
6Tab with sticky headers, cookie banners and chat panels present; repeat at 400% zoom on a 1280 CSS px window, which SC 1.4.10 Reflow equates to a 320 CSS px width2.4.11The focused control is never entirely behind author-created content
7Open and close each dialog, menu and disclosure; delete a list item; submit an invalid form2.4.3Focus goes to the expected element, never to the page body
8Complete the whole task, success and error paths2.1.1Result achieved by keyboard alone

Record each defect as: URL, browser and operating system, starting state, exact keys, the first point of failure, the expected focus destination and the observed one. “Keyboard support is broken” cannot be fixed; “Shift+Tab from the Save button in the delivery dialog lands on the page header instead of Cancel” can.

Automated scanners can flag some of these failures, but the W3C’s guidance on evaluation tools is that they “cannot check all accessibility aspects automatically” and that “human judgement is required.” Focus order and widget behavior call for that judgement, so treat a scanner as a source of leads and rely on manual passes for steps 3 and 4. Run the pass again after a fix, in both directions, and on every place that uses the shared component. Pointer target size is a separate question: see touch target sizes.

Common failures mapped to fixes

ObservationProbable causeFix
Clicking works, Enter does nothingClick handler on a non-interactive element (fails 2.1.1)Replace with a native button or a href
Focus ring missing after TabGlobal outline: none (F78)Remove the reset or add a :focus-visible style
Tab order jumps around the layoutCSS order or positive tabindex (F44)Fix DOM order; remove positive values
Focus sinks beneath the footerSticky element with no scroll-padding (F110)Add scroll-padding or let the sticky element release on focus
Cannot leave an iframe or widgetComponent consumes Tab (2.1.2)Provide a standard exit and tell users how
After closing a dialog, focus returns to the topFocus not restoredStore the opener and call focus() on close

Sources