Why this matters
About 26% of adults in the US have a disability. Many use only a keyboard to navigate — including people with motor disabilities, power users, and those using screen readers. Keyboard inaccessibility is a complete blocker for these users.
Code examples
✗ Incorrect — fails WCAG
<!-- div used as button - not keyboard focusable --> <div onclick="submitForm()" class="btn">Submit</div> <!-- Custom dropdown with no keyboard support --> <div class="dropdown" onclick="toggle()">Menu</div>
✓ Correct — passes WCAG
<!-- Real button - keyboard focusable by default --> <button onclick="submitForm()" class="btn">Submit</button> <!-- Keyboard accessible dropdown --> <button aria-expanded="false" aria-controls="menu">Menu</button> <ul id="menu" role="menu">...</ul>
How to fix it — step by step
- 1Use native HTML elements — <button>, <a>, <input>, <select> — they are keyboard accessible by default
- 2Never use <div> or <span> as interactive elements unless you add tabindex='0' and keyboard event handlers
- 3Test your entire site using only the Tab, Enter, Space, and Escape keys
- 4Modals and dialogs must trap focus inside while open — users shouldn't be able to Tab behind them
- 5Add keyboard event listeners alongside click handlers for custom components
- 6Make sure dropdown menus can be opened and closed with keyboard
- 7Use tabindex='0' to add elements to tab order, tabindex='-1' to remove them
Reference: WCAG 2.2 Success Criterion 2.1.1 (Level A)
Test it for free
Use WebPossum to automatically detect this violation and every other WCAG 2.2 issue on your site. Free, instant, no signup required.