Keyboard Trap Detector
Analyze HTML for keyboard traps, positive tabindex anti-patterns, focusable elements inside aria-hidden, missing skip links, and modal focus management.
We fetch the page client-side. Some sites may block external access — use "Paste HTML" as a fallback.
How to Use Keyboard Trap Detector
- 1
Paste your HTML
Copy the HTML source code of the page you want to analyze for keyboard traps and focus issues.
- 2
Click Analyze
Press the Analyze button to parse all focusable elements and detect potential keyboard traps.
- 3
Review tab order
View the visual tab order flow diagram to understand how keyboard focus moves through your page.
- 4
Fix issues
Address errors like focusable elements inside aria-hidden and warnings like positive tabindex values.
Frequently Asked Questions
Related Tools
Keyboard Accessibility: A Fundamental Requirement
Keyboard accessibility is one of the four foundational principles of WCAG and affects more users than many developers realize. Beyond screen reader users, keyboard navigation is essential for users with motor impairments who cannot use a mouse, power users who prefer keyboard shortcuts, users with temporary injuries, and users of alternative input devices that emulate keyboard input. When keyboard traps exist, these users become completely blocked from completing their tasks.
How Keyboard Traps Occur
Keyboard traps most commonly occur in modal dialogs that capture focus without providing an Escape key handler, custom widget implementations that use JavaScript to redirect focus back to themselves, embedded content like iframes or third-party widgets that do not properly manage focus, and auto-focus behaviors that override user-initiated focus changes. Less obvious traps include components that visually disappear but retain focus, and roving tabindex implementations that fail to handle edge cases.
Understanding Tab Order
The tab order of a page is determined by the DOM order of focusable elements, modified by tabindex values. Elements with positive tabindex values are focused first (in order of their tabindex value), followed by elements with tabindex='0' or no tabindex in DOM order. Elements with tabindex='-1' are removed from the tab order but can receive focus programmatically. The natural DOM order should match the visual reading order, and positive tabindex values should be avoided because they create maintenance challenges and confusing navigation patterns.
Best Practices for Focus Management
Always ensure modal dialogs trap focus within the dialog while it is open and restore focus to the triggering element when closed. Provide Escape key handling for any component that traps focus. Use aria-modal='true' on dialog elements. Never place focusable elements inside aria-hidden containers. Add skip links as the first focusable element on every page. Test keyboard navigation regularly by unplugging your mouse and attempting to complete all user journeys using only the keyboard.