Remediation guide
How to Test Keyboard Navigation Accessibility
Keyboard inaccessibility is cited in a significant portion of ADA website demand letters — second only to missing alt text. A user who navigates by keyboard (due to motor disability, a broken mouse, or personal preference) must be able to reach and operate every link, button, form field, and interactive widget on your site using only the keyboard. This guide walks through the complete testing protocol and the fixes for the most common failures.
- WCAG criteria
- Testing protocol
- What to check
- Common failures
- Fix patterns
- Automated tools
- Verify with ShipSafe
- FAQ
The WCAG success criteria you're testing against
Four success criteria from WCAG 2.1 and 2.2 cover keyboard access. All four appear in ADA demand letters and automated audit reports.
2.1.1 Keyboard
All functionality must be operable through a keyboard interface without requiring specific timing for individual keystrokes. Any action a mouse user can perform — clicking a button, navigating a menu, filling a form, playing media — must also be achievable with the keyboard alone.
2.1.2 No Keyboard Trap
If keyboard focus can be moved into a component, it must be movable out of that component using standard keys (Tab, Shift+Tab, or Escape). Embedded maps, third-party widgets, and poorly implemented modal dialogs are common sources of keyboard traps.
2.4.3 Focus Order
If a web page can be navigated sequentially, the focus order must preserve meaning and operability. Components that appear visually at the top of the page but are last in the DOM — due to absolute positioning, float layout, or flexbox reordering — often produce illogical, disorienting focus sequences.
2.4.7 Focus Visible
Any keyboard-operable user interface component must have a visible focus indicator. Many sites suppress the browser's default focus outline with outline: none or outline: 0 in their CSS reset and replace it with nothing, making the focused element invisible to keyboard users.
The keyboard testing protocol
Set down your mouse. Navigate the full page from top to bottom using only these keys. Each key tests a different aspect of keyboard accessibility.
| Key | What it does | What you’re checking |
|---|---|---|
| Tab | Moves focus to the next interactive element in DOM order | Focus is visible on the element; every interactive element (links, buttons, inputs, selects) receives focus; non-interactive elements (paragraphs, divs) are skipped |
| Shift+Tab | Moves focus backward through the tab sequence | Backward navigation is possible; focus order is consistent in both directions |
| Enter | Activates links (navigates); activates buttons; submits forms | Links navigate to their destination; buttons fire; form submits — same as a mouse click |
| Space | Activates buttons and checkboxes; scrolls the page when focus is not on an element | Buttons respond to Space (not just Enter); checkboxes toggle; radio buttons do NOT toggle with Space — they use arrow keys |
| Arrow keys | Navigate within components that contain multiple focusable items | Radio groups, custom dropdown menus, tab panels, sliders, comboboxes, tree views, data grids — all navigate with arrow keys while Tab moves focus to and from the whole component |
| Escape | Closes dialogs, menus, popovers, and tooltips; cancels in-progress operations | Every open overlay closes; focus returns to the element that triggered it |
| Home / End | Jumps to the first / last item in certain components | Sliders, listboxes, and grid cells typically support Home/End per the ARIA design patterns |
5 things to check as you tab through the page
-
Is the focused element always visible on screen?
As you Tab, can you see which element has focus at all times? The browser default outline — a blue ring on Chrome, a dashed border on Firefox — is your baseline. If an element receives focus but you can’t see a visible indicator, the site has likely applied
outline: noneor:focus { outline: 0 }in CSS without providing a replacement. This is a WCAG 2.4.7 failure. Also check for scroll: does the page auto-scroll to keep the focused element in view, or can focus move off-screen while the user can’t tell where they are? -
Is the focus order logical?
Focus should move through the page in a sequence that matches the visual reading order — generally left-to-right, top-to-bottom. Layouts built with CSS absolute positioning, negative margins, flexbox
order, or CSS Grid placement can produce a DOM order that diverges from visual order. Tab through the page and notice: does focus jump unexpectedly between header, sidebar, and footer? Does a modal or off-canvas navigation that appears visually above everything else receive focus after the main content? These are WCAG 2.4.3 Focus Order failures. -
Can you reach every interactive element?
Every link, button, form field, select, checkbox, radio button, and custom interactive widget must appear in the tab sequence. Interactive elements that are only accessible via mouse hover (like certain dropdown menus that open on
:hoverwith no keyboard alternative) are WCAG 2.1.1 failures. Also watch for elements that are in the tab order but shouldn’t be — non-interactive elements like decorative images or hidden elements that receivedtabindex="0"accidentally. -
Can you escape every component you enter?
Tab into each section of the page and check that you can Tab back out. Focus on a date picker, embedded map, or rich-text editor — can you leave using Tab or Escape? Modal dialogs intentionally contain focus while open, but must respond to Escape. Carousels, video players, and third-party widgets are common traps. If you press Escape and the dialog closes, verify that focus returns to the button that opened it — not to the top of the page or to
document.body. -
Does every custom interactive element behave like its native counterpart?
A custom button built from a
<div>should respond to both Enter and Space, just like a native<button>. A custom dropdown should respond to Arrow keys for options, Enter to select, and Escape to close — matching the behavior of a native<select>. A custom checkbox should toggle with Space. Test each non-native interactive component against the ARIA Authoring Practices Guide keyboard interaction patterns (opens in new tab) for the corresponding widget type.
Common keyboard accessibility failures
Focus outline removed, no replacement
The most widespread keyboard failure: * { outline: none } or :focus { outline: 0 } in a CSS reset, with nothing to replace the browser’s default ring. Every interactive element on the page becomes invisible to keyboard users.
- Search your CSS for
outline: noneandoutline: 0 - Replace with a custom focus style or use
:focus-visibleto show focus only for keyboard (not mouse) interaction
Modal dialog without focus management
Modal opens but focus stays on the trigger behind it; or focus enters the modal but Tab escapes to the document; or modal closes but focus is lost (sent to body). All three patterns appear in ADA demand letters.
- Move focus to modal on open (first focusable element or dialog container)
- Trap Tab within modal while open
- Return focus to trigger on close
- Respond to Escape to close
Missing skip navigation link
Without a skip link, keyboard users must Tab through every item in your navigation header on every page before reaching the main content. A page with 20 nav items means 20 Tab presses to reach the first link in the article.
- Add
<a class="skip" href="#main">Skip to main content</a>as the first element in<body> - Show it only on keyboard focus (visually hidden by default, visible on
:focus)
Custom interactive elements not in tab order
Buttons and links built from div, span, or a href="#" without tabindex or correct ARIA roles. Mouse users see a clickable element; keyboard users never reach it.
- Use native
<button>and<a href>wherever possible - If you must use a non-native element, add
tabindex="0", the appropriaterole, and keyboard event listeners
Hover-only menus
Navigation dropdowns that open on CSS :hover or a mouseover JS event without a keyboard equivalent. The items inside the dropdown are unreachable via Tab if the dropdown never opens.
- Open the dropdown on Enter/Space on the parent button, not just hover
- Navigate items with Arrow keys; close with Escape
- Or use the disclosure navigation pattern (each level is a separate page or expandable region)
Positive tabindex values
tabindex="1", tabindex="2", etc. create a custom tab order that overrides the DOM order. Elements with positive tabindex receive focus before all tabindex="0" elements, typically producing a disorienting, illogical sequence — a WCAG 2.4.3 violation.
- Remove all positive tabindex values
- Fix DOM order to match visual order instead of manipulating tabindex
- Use only
tabindex="0"andtabindex="-1"
Fix patterns
Fix 1: Restore focus indicators with :focus-visible
Replace blanket outline: none with a targeted rule that removes outlines only for mouse/touch interaction while keeping them for keyboard navigation:
/* Remove default outline for mouse/touch, keep it for keyboard */
:focus:not(:focus-visible) {
outline: none;
}
/* Custom keyboard focus style */
:focus-visible {
outline: 3px solid #0070f3;
outline-offset: 2px;
border-radius: 3px;
}
/* High contrast support */
@media (forced-colors: active) {
:focus-visible {
outline: 3px solid ButtonText;
}
}
:focus-visible is supported in all modern browsers. For older browser support, use the focus-visible polyfill (opens in new tab).
Fix 2: Skip navigation link (visually hidden until focused)
<!-- First element inside <body> -->
<a class="skip-link" href="#main">Skip to main content</a>
<!-- Target -->
<main id="main">...</main>
/* CSS: visually hidden, shown on focus */
.skip-link {
position: absolute;
left: -9999px;
top: 8px;
z-index: 9999;
background: #000;
color: #fff;
padding: 8px 16px;
border-radius: 4px;
font-weight: 600;
text-decoration: none;
}
.skip-link:focus {
left: 8px;
}
Fix 3: Keyboard-accessible modal dialog
class FocusTrap {
constructor(element) {
this.el = element;
this.focusable = 'a[href], button:not([disabled]), input, select,
textarea, [tabindex="0"]';
}
getFocusable() {
return [...this.el.querySelectorAll(this.focusable)]
.filter(el => !el.closest('[hidden]'));
}
open(trigger) {
this.trigger = trigger;
this.el.removeAttribute('hidden');
const items = this.getFocusable();
if (items.length) items[0].focus();
else this.el.focus(); // dialog needs tabindex="-1"
this.el.addEventListener('keydown', this._handleKey);
}
close() {
this.el.setAttribute('hidden', '');
this.el.removeEventListener('keydown', this._handleKey);
this.trigger?.focus();
}
_handleKey = (e) => {
if (e.key === 'Escape') { this.close(); return; }
if (e.key !== 'Tab') return;
const items = this.getFocusable();
const first = items[0], last = items[items.length - 1];
if (e.shiftKey) {
if (document.activeElement === first) { e.preventDefault(); last.focus(); }
} else {
if (document.activeElement === last) { e.preventDefault(); first.focus(); }
}
};
}
// Usage
const trap = new FocusTrap(document.getElementById('my-dialog'));
document.getElementById('open-btn').addEventListener('click', e => trap.open(e.currentTarget));
document.getElementById('close-btn').addEventListener('click', () => trap.close());
<dialog> element handles much of this automatically in modern browsers: it traps focus, responds to Escape, and moves focus to the first focusable child on open. Use it when you can — polyfill with the dialog polyfill (opens in new tab) for older browsers.
Fix 4: Custom button from a non-native element
<!-- Avoid this: div receives click but not keyboard events -->
<div class="btn" onclick="doAction()">Save</div>
<!-- Use a native button instead (preferred) -->
<button type="button" class="btn" onclick="doAction()">Save</button>
<!-- If you must keep the div (legacy code), add ARIA + keyboard -->
<div class="btn"
role="button"
tabindex="0"
onclick="doAction()"
onkeydown="if(e.key==='Enter'||e.key===' '){e.preventDefault();doAction()}">
Save
</div>
Native <button> handles Tab, Enter, Space, and disabled state for free. The role="button" workaround requires you to reimplement all of that manually and is easy to get wrong.
Automated tools
Manual keyboard-only test (highest coverage)
Unplug or disable your mouse. Tab through every page of your site. There is no substitute — automated tools can detect many structural issues, but only a manual keyboard walkthrough catches focus order problems, hover-only interactions, and the subjective experience of keyboard navigation.
Axe DevTools browser extension (free)
The Axe DevTools extension for Chrome and Firefox identifies keyboard accessibility violations in the rendered DOM, including: interactive elements that don’t have accessible names, tabindex values greater than 0, ARIA roles missing required keyboard behavior, and elements with aria-hidden="true" that are still focusable. Install it, open DevTools, and run the scan. Results include the specific failing element and a direct link to the WCAG criterion.
ShipSafe (quick HTML source check)
Paste your URL into ShipSafe for a fast scan of the page’s HTML source. ShipSafe checks for the presence of a skip navigation link, common focus-suppression patterns in inline styles, and interactive-element patterns that suggest keyboard inaccessibility. It’s fastest as a first pass before a full manual test.
axe-core CLI (for CI integration)
npx axe-core-cli <url> --tags wcag2a,wcag2aa --reporter json > axe-report.json
This produces a JSON report of all WCAG A and AA violations detected in the rendered page. Run it in CI before every deploy to catch regressions. Note: automated tools detect roughly 30–40% of real accessibility issues; the remaining failures require manual testing.
Verify with ShipSafe
After applying fixes, run ShipSafe on your URL. Look for the Accessibility section in the results — a green check next to keyboard-related items confirms the structural indicators ShipSafe looks for are in place. For a complete picture, run the Axe DevTools scan from within the browser after the page fully renders, then do a final manual keyboard walkthrough from the top of the page to the bottom with no mouse.
Keyboard accessibility is process, not a one-time fix: new features, third-party widgets, and framework upgrades can reintroduce failures. Make keyboard testing part of your pre-deploy checklist.
Related ShipSafe guides:
- ADA compliance checklist for developers — 30 testable WCAG 2.1 AA items
- WCAG remediation checklist for existing websites
- How to fix missing alt text on images — WCAG 1.1.1
- Received an ADA demand letter? What to do first
Frequently asked questions
Which WCAG success criteria cover keyboard navigation?
Four success criteria are directly relevant:
- 2.1.1 Keyboard (Level A): all functionality must be operable through a keyboard interface without requiring specific timing.
- 2.1.2 No Keyboard Trap (Level A): if focus can move into a component, it can move out using standard keys (Tab or Escape).
- 2.4.3 Focus Order (Level A): if a page can be navigated sequentially, the focus order must preserve meaning and operability.
- 2.4.7 Focus Visible (Level AA): keyboard-operable interfaces must have a visible focus indicator.
WCAG 2.2 added 2.4.11 Focus Appearance (Level AA), requiring a minimum size and contrast ratio for focus indicators.
What keys do I use during keyboard accessibility testing?
Tab (forward), Shift+Tab (backward), Enter (links and buttons), Space (buttons and checkboxes), Arrow keys (within components: radio groups, menus, sliders), Escape (close dialogs and menus), and Home/End (first/last in some components). Test with only these keys — no mouse — from the top of the page to the bottom.
What does “keyboard trap” mean in WCAG?
A keyboard trap (WCAG 2.1.2) occurs when focus enters a component but cannot exit using standard keyboard keys. Embedded maps and iframes are common unintentional traps. Modal dialogs intentionally trap focus while open — that is correct behavior — but must allow Escape as an exit and must return focus to the trigger element on close. The failure is when there is no documented way out of a component.
What is tabindex and when should I use it?
tabindex="0" adds a non-interactive element to the natural tab order — use it on custom interactive widgets. tabindex="-1" makes an element programmatically focusable via element.focus() without adding it to the tab sequence — use it on dialog containers and error summaries. Positive tabindex values (tabindex="1", etc.) override natural DOM order and almost always create WCAG 2.4.3 Focus Order violations. Never use positive values.
How do I make a modal dialog keyboard accessible?
Four requirements: (1) Move focus into the modal on open — to the first focusable element or the dialog container. (2) Trap Tab inside while the modal is open. (3) Close on Escape. (4) Return focus to the trigger on close. Add role="dialog" and aria-modal="true" to the container, and aria-labelledby pointing to the heading. The native HTML <dialog> element handles this in modern browsers with less custom code.
Why does my custom dropdown work with a mouse but fail keyboard testing?
Custom dropdowns built from <div> or <span> receive mouse click events but aren’t in the tab order and don’t handle keyboard events by default. For keyboard access, the trigger needs tabindex="0" (or should be a <button>), appropriate ARIA role, and keyboard event listeners for Enter, Space, Arrow keys, and Escape. The native <select> element is fully keyboard-accessible without additional code — use it for simple selection controls.
Does ShipSafe check keyboard accessibility?
ShipSafe scans the page’s HTML source for structural patterns associated with keyboard failures: missing skip links, inline styles that suppress focus indicators, and custom interactive elements that may lack keyboard support in their markup. For comprehensive testing, combine ShipSafe’s quick source scan with a manual keyboard walkthrough (no mouse, Tab through the full page) and the Axe DevTools browser extension for rendered-DOM analysis.
Also in the Copper Bay Labs suite
Keyboard accessibility is one dimension of ADA and WCAG risk. These free tools cover the rest:
Generate a privacy policy, terms of service, and cookie notice for your site — free, in your browser, no account.
Security headers HardenCheckScan your live site’s HTTP headers for missing CSP, HSTS, and other security hardening flags.
Secret scanning LeakCheckPaste code or a config file and see exposed API keys and secrets flagged before they reach the repo.
Post-deploy ExposureCheckScan your live URL for exposed .env files, .git directories, source maps, and bundled secrets.