/qa-accessibility:wcag-keyboard-navigationfrom qa-accessibility
Verifies WCAG 2.2 keyboard-navigation conformance: keyboard operability, no keyboard traps, focus order, visible focus, and focus-trap patterns for modals/drawers/popovers. Includes Playwright test scripts.
Ships in qa-accessibility. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Reference catalog for how to verify keyboard-navigation conformance. Pairs with the scanner umbrella
axe-a11y(axe-core, pa11y, Lighthouse a11y).
WCAG 2.2 organizes accessibility into four principles - Perceivable / Operable / Understandable / Robust - at three conformance levels - A / AA / AAA (wcag22).
Keyboard navigation lives under Operable (Principle 2) and spans six key Success Criteria covering keyboard operability, focus management, and focus visibility.
axe-a11y.Per wcag22: "All functionality of the content is operable through a keyboard interface" without requiring specific timings. Path-dependent input (handwriting) is exempt.
| Pattern | What to test |
|---|---|
<button>, <a href>, <input> | Native - already keyboard-accessible. |
<div onclick="..."> | Anti-pattern. Non-focusable; not keyboard-operable. Convert to <button>. |
Custom widget (role="button", tabindex="0") | Verify Enter / Space activates the same handler. |
| Drag-and-drop | Provide a keyboard alternative (arrow keys + Enter, or button-based reorder). |
Test script (Playwright):
test('SC 2.1.1 - interactive elements are keyboard-operable', async ({ page }) => {
// Tab to the button, activate with Enter
await page.keyboard.press('Tab');
await page.keyboard.press('Enter');
await expect(page.locator('[data-testid="action-result"]')).toBeVisible();
// Repeat with Space for elements that should accept Space
await page.keyboard.press('Tab');
await page.keyboard.press('Space');
await expect(...).toBeVisible();
});
Per wcag22: "Focus must be movable away using standard methods; users should be informed of exit procedures if non- standard keys are required."
| Common failure | Fix |
|---|---|
| Modal traps Tab without an explicit Escape handler | Add Escape handler that closes the modal and restores focus. |
Embedded <iframe> (e.g. third-party widget) traps Tab | Set tabindex="-1" on the iframe OR document the exit (Esc + Tab) in surrounding label. |
| Custom date picker locks focus inside on first focus | Provide Tab to exit the calendar and continue to the next field. |
See references/focus-trap.md for the intentional-trap convention (modal focus management) which is distinct from a violation.
Single-character shortcuts (/ to focus search, j/k to
navigate items) must offer at least one of:
This SC exists because users with speech-input software produce spurious key presses; unguarded single-character shortcuts trigger unintended actions.
Per wcag22: components must "receive focus in an order that preserves meaning and operability."
| Pattern | What to test |
|---|---|
| Reading-order vs DOM-order vs visual-order | All three should agree. CSS order / flex-direction: row-reverse can desync visual from DOM. |
tabindex="3" (positive) | Anti-pattern. Positive tabindex creates explicit focus order separate from DOM; rarely intended. Use 0 or -1. |
| Modal that doesn't trap focus | Tab moves focus to the page behind; user loses context. |
| Skip links | Always at the start of the document; tabindex="0" not needed (anchor links are focusable). |
Per wcag22: "Any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible."
| Failure | Fix |
|---|---|
*:focus { outline: none; } without alternative | Replace with :focus-visible style: :focus-visible { outline: 2px solid var(--focus-ring); }. |
| Subtle 1px gray ring on a gray background | 3:1 contrast ratio against background per WCAG SC 1.4.11; high-contrast theme should bump to 4.5:1. |
| Disabled focus indicator on hover | Hover and focus styles are independent; never tie them. |
Per wcag22: components receiving focus cannot be "entirely hidden due to author-created content."
| Failure pattern | Fix |
|---|---|
| Sticky header covers the focused input on long-form pages | Adjust scroll-margin-top so focused element scrolls into view below the sticky header. |
| Persistent cookie banner covers focused element | Modal / overlay should NOT obscure focused content; use compact banner or temporarily hide. |
| Auto-popup chat widget overlays focused fields | Render below other content OR move to a corner that doesn't intersect with form fields. |
2.4.11 (Minimum, Level AA): focus must NOT be entirely obscured.
2.4.12 (Enhanced, Level AAA): focus must NOT be partially obscured. Stricter; relevant for high-stakes forms.
<label for="..."> or
aria-labelledby.(See references/focus-trap.md for the full modal pattern.)
This matches the ARIA Menu pattern (referenced from
aria-authoring-patterns).
The patterns above translate to per-test assertions in
axe-a11y configurations. The
a11y-violation-gate skill
gates the build on new violations of these SCs.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
<div onclick> for buttons | Not focusable, not Enter-activatable. | Always <button type="button">. |
outline: none for clean design | Removes focus indicator entirely (SC 2.4.7). | :focus-visible { outline: 2px solid <color>; }. |
tabindex="3" to control focus order | Creates a non-DOM order; breaks on dynamic content. | DOM-order tabbing; tabindex="0" for custom focusables, -1 to skip. |
| Single-character shortcuts always-active | Triggered by speech-input users (SC 2.1.4). | Off / remap / focus-only. |
| Sticky header obscures focused input | Violates SC 2.4.11. | scroll-margin-top per element. |
<dialog>, test scripts).wcag-color-contrast -
for SC 1.4.11 focus-indicator contrast.aria-authoring-patterns - for canonical interactive-widget patterns.axe-a11y - scanners that
detect SC violations programmatically.evals/aa-signoff-on-a-checkout-with-two-sticky-bars/criteria.json (opens in a new tab)evals/aa-signoff-on-a-checkout-with-two-sticky-bars/task.md (opens in a new tab)evals/kanban-cards-that-only-move-by-mouse/criteria.json (opens in a new tab)evals/kanban-cards-that-only-move-by-mouse/task.md (opens in a new tab)evals/power-user-shortcuts-archiving-mail-nobody-touched/criteria.json (opens in a new tab)evals/power-user-shortcuts-archiving-mail-nobody-touched/task.md (opens in a new tab)evals/procurement-audit-finding-on-our-hand-rolled-dialog/criteria.json (opens in a new tab)evals/procurement-audit-finding-on-our-hand-rolled-dialog/task.md (opens in a new tab)evals/tab-strip-where-arrows-move-the-panel-but-not-the-reader/criteria.json (opens in a new tab)evals/tab-strip-where-arrows-move-the-panel-but-not-the-reader/task.md (opens in a new tab)references/focus-trap.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
wcag, a11y, keyboard-navigation, focus-management, playwright
7 skills in this plugin
/a11y-violation-gateUse when a project has accessibility debt and a zero-violations gate would block every PR. Builds a CI ratchet that fails only on new WCAG violations a PR introduces, with pre-existing ones baselined per rule and page, from axe-core, pa11y, Lighthouse, WAVE or IBM Equal Access results./aria-authoring-patternsUse when building or reviewing a custom interactive widget with no native HTML equivalent (combobox, dialog, menu, tabs, tree and more). Gives the W3C ARIA Authoring Practices pattern: required roles and states, keyboard interaction and common violations./axe-a11yUse for any request to check accessibility automatically, including adding a scan to an existing Playwright, Cypress or unit test, or stopping missing labels and contrast errors from shipping: axe-core via axe.run(), @axe-core/playwright or the CLI on every PR, rule configuration and CI-gateable results, plus pa11y, Lighthouse CI, WAVE and IBM Equal Access in its references./screen-reader-test-authorUse when a feature needs manual screen-reader testing before sign-off: step-by-step scripts for NVDA, JAWS, VoiceOver or TalkBack with keystrokes and expected announcements, WCAG 2.2 checklists per page type, widget keystroke matrices and a guided session with a signed report./wcag-color-contrastUse for any question about color contrast or whether colors pass WCAG, including quick checks of a few hex values and hard-to-read text: WCAG 2.2 text, large-text and non-text contrast ratios (4.5:1, 3:1) at AA and AAA, the measurement formula, palette and component reviews, and bulk checks over CSS and design tokens./wcag-compliance-reporterUse after an accessibility scan across many pages (pa11y-ci, axe over a sitemap, Lighthouse batch) when the team needs a shareable conformance report. Groups violations by WCAG 2.2 success criterion and level, flags pages that were not scanned and writes a summary plus per-page detail.npx claudepluginhub testland/qa --plugin qa-accessibilityOther plugins' skills for the same job