Back to blog
Accessibility·October 2026·9 min read

Keyboard navigation for ecommerce stores: a testing and implementation guide

Keyboard accessibility is the foundation of web accessibility. Screen readers, switch access devices, voice control software and many other assistive technologies all depend on correct keyboard navigation. Users who cannot use a mouse rely on the keyboard to browse, select products, fill out forms and complete purchases.

WCAG 2.1.1 (Keyboard, Level A) requires that all functionality is operable via keyboard. This is one of the most frequently violated WCAG criteria on ecommerce sites. In Complyko's scan data from 382 stores, 89% had at least one keyboard navigation failure on their checkout or cart flows.

This guide covers the specific keyboard accessibility patterns required in ecommerce: tab order, focus indicators, skip links, focus trapping, carousels, mega menus, filters, quantity steppers and checkout form navigation. For the full list of applicable criteria, see our WCAG 2.1 AA ecommerce checklist.

What does WCAG 2.4.7 require for focus indicators?

WCAG 2.4.7 (Focus Visible, Level AA) requires that any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible. This means the currently focused element must be visually distinguishable from unfocused elements.

WCAG 2.2 added 2.4.11 (Focus Appearance, Level AA), which is more specific: the focus indicator must have a minimum area, a contrast ratio of at least 3:1 between focused and unfocused states, and not be entirely enclosed by the element boundary (a simple inset box shadow on a button does not fully comply with 2.4.11).

In practice, the most common focus indicator failure is outline: none or outline: 0 applied globally in CSS. This single CSS rule makes the entire site keyboard inaccessible from a visual standpoint. Every ecommerce site should:

  • Remove global outline: none rules from stylesheets.
  • Define a custom focus style using :focus-visible that matches the site's design while remaining visible: a 2px or 3px solid outline in a contrasting color, or a high-visibility box shadow.
  • Use :focus-visible instead of :focus for custom focus styles to avoid showing focus rings on elements that are clicked with a mouse (modern browsers support this natively).

How should skip navigation links work on ecommerce sites?

WCAG 2.4.1 (Bypass Blocks, Level A) requires a mechanism to skip repeated navigation. A skip navigation link is the standard solution: the first focusable element in the page is a link that, when activated, moves focus past the navigation to the main content.

Correct implementation:

  • The skip link is the first focusable element in the DOM (above the navigation, in the HTML source order).
  • The link is visible when focused. Common approach: visually hidden by default, revealed on focus with :focus { position: static; clip: auto; }.
  • The link's target is the <main> element or a container with id="main-content". The target element has tabindex="-1" to receive programmatic focus.
  • When activated (Enter key), focus moves to the target and the page scrolls to that position.

Common failure modes: skip links present in the HTML but hidden with display: none (removes them from tab order entirely), skip link targets without tabindex="-1" (focus does not move correctly in some browsers), and multiple pages having a skip link that points to an element that does not exist on that specific page.

For ecommerce stores, consider additional skip links for frequently repeated sections: "Skip to product filters", "Skip to search results" on category pages, and "Skip to order summary" on checkout pages.

What is the correct tab order for an ecommerce page?

Tab order should match visual reading order: left to right, top to bottom in left-to-right languages. Unexpected tab order is a WCAG 2.4.3 (Focus Order, Level A) failure.

Tab order violations on ecommerce pages occur when:

  • CSS absolute or fixed positioning moves elements visually away from their DOM position. The DOM order determines tab order; CSS positioning does not change it. An "Add to Wishlist" button positioned visually above the add-to-cart button but placed later in the DOM receives focus after the add-to-cart button in the tab sequence.
  • tabindex values greater than 0 are used to force a specific focus order. Positive tabindex values take precedence over natural DOM order and create complex, hard-to-maintain focus sequences. Avoid positive tabindex values entirely. Use only tabindex="0" (adds to natural order) and tabindex="-1" (removes from order, allows programmatic focus).
  • Two-column layouts (product image on left, product details on right) where the DOM order has both columns interspersed rather than sequential.

How to implement keyboard-accessible mega menus

Navigation mega menus are one of the most complex keyboard accessibility challenges in ecommerce. The standard pattern per W3C ARIA Authoring Practices Guide uses a disclosure pattern:

  • Top-level navigation items are <button> elements (or links that also trigger submenus with Enter/Space).
  • Pressing Enter or Space on a top-level item opens its submenu panel and moves focus into the panel.
  • Within the submenu panel, arrow keys navigate between links. Left/right arrows navigate between top-level items (closing the current panel and opening the adjacent one).
  • Pressing Escape closes the open panel and returns focus to the triggering top-level item.
  • Tab moves focus out of the navigation entirely.

The alternative pattern for simpler navigation: top-level items open submenus on focus (not just hover), and Tab key navigates through submenu items before moving to the next top-level item. This pattern is simpler to implement but can make navigation slow for keyboard users who must Tab through every link in every submenu.

Whichever pattern you choose, the critical requirement is that submenu items are reachable via keyboard and that the pattern behaves consistently and predictably.

Focus trapping in modal dialogs and cart drawers

When a modal dialog or off-canvas panel is open, keyboard focus must be trapped within it. Users pressing Tab should cycle through only the interactive elements inside the modal, not reach content behind it.

Implementation steps:

  • Identify the first and last focusable elements inside the modal.
  • When focus reaches the last element and the user presses Tab, move focus to the first element.
  • When focus reaches the first element and the user presses Shift+Tab, move focus to the last element.
  • Use the HTML inert attribute on page content outside the modal to prevent background interaction. The inert attribute is now supported in all modern browsers and is the cleanest solution.

Common JavaScript implementation: query all focusable elements within the modal (button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])), get the first and last, and add keydown event listeners that cycle focus at the boundaries.

When the modal closes, focus must return to the element that triggered it. Store a reference to the triggering element before opening the modal and call triggerElement.focus() when the modal closes.

Keyboard accessibility for product image carousels

Product image carousels on product pages need specific keyboard patterns. The W3C carousel pattern defines two interaction models: auto-rotating carousels and static carousels. For product image galleries, the static (non-auto-rotating) carousel pattern is appropriate.

Required behavior:

  • Previous and next buttons are <button> elements with accessible names ("Next image", "Previous image", not just arrow characters).
  • The carousel container has role="group" and aria-label="Product images" or aria-roledescription="carousel".
  • Each slide has role="group" and aria-label="2 of 5" or similar positional information.
  • Thumbnail navigation buttons, if present, use the roving tabindex pattern: one thumbnail at a time is in the tab order (tabindex="0"), the rest have tabindex="-1". Arrow keys move between thumbnails.

The roving tabindex pattern for product option selectors

The roving tabindex pattern is the correct keyboard navigation model for groups of related controls where only one can be selected at a time: size selectors, color swatches, shipping method radio buttons and similar controls.

In the roving tabindex pattern:

  • The entire group receives a single Tab stop. The currently selected or focused option has tabindex="0". All other options have tabindex="-1".
  • Arrow keys move focus between options within the group. Moving focus with arrow keys also selects the option (for single-selection groups like size selectors).
  • Tab moves focus out of the group entirely, to the next element in the page's tab sequence.

This pattern significantly reduces the number of Tab presses required to navigate through a product page with many variant options. Without roving tabindex, a product page with 10 size options, 6 color options and a length option requires 17 Tab presses just to move through the variant selectors. With roving tabindex, it requires 3.

Keyboard accessibility for accordion filter panels

Accordion-style filter panels (e.g., "Size", "Color", "Brand" sections that expand and collapse) require specific keyboard patterns.

  • Each accordion header is a <button> element. Pressing Enter or Space toggles the associated content panel open or closed.
  • The button has aria-expanded="true" when the panel is open, aria-expanded="false" when closed.
  • The button has aria-controls pointing to the panel element's ID.
  • When the panel opens, focus stays on the header button. Users Tab into the panel content.
  • Tab moves naturally through the filter options within the panel.

Filter option checkboxes need standard checkbox keyboard behavior: Space toggles the checkbox. Enter should not toggle checkboxes (Enter activates links and buttons; using Enter on a checkbox follows the native browser behavior which is to submit the nearest form, not toggle the checkbox). For the full pattern including AJAX result announcements, see our guide on accessible search and product filters.

Keyboard navigation for checkout forms

Checkout forms have specific keyboard navigation requirements beyond standard form accessibility. Our checkout accessibility guide covers the full scope of checkout compliance.

  • Field sequence. The tab order through address fields should follow natural address entry order: first name, last name, address line 1, address line 2, city, state/province, postcode, country. Unusual field ordering forces users to re-read labels to understand where they are.
  • Dependent field updates. When changing the country field updates the state/province field options (via AJAX), the updated options must be reachable by keyboard and announced to screen reader users. Focus should remain on the country select, and a live region should announce when the state options have loaded.
  • Error handling. When form submission fails due to validation errors, focus should move to the first error message or the error summary. Users should not need to Tab through the entire form to discover which fields failed.
  • Payment field iframes. Payment processor card inputs rendered in iframes (Stripe Elements, Braintree) are keyboard accessible by design. Tab moves focus into the iframe. Shift+Tab exits it. Test this explicitly: some iframe implementations lose keyboard focus when users try to Tab out.
  • Step completion. In multi-step checkouts, when completing a step and moving to the next, focus should move to the new step heading or the first field in the new step. Do not leave focus at the submit button of the completed step pointing to a now-hidden element.

How to test keyboard navigation on an ecommerce store

Keyboard testing requires discipline. Disconnect or disable your mouse and test the following flows:

  • Navigate to a product category from the homepage using only the keyboard.
  • Apply at least two filters to narrow the product list.
  • Navigate to a product page. Select a size and color variant. Change the quantity.
  • Add the product to the cart. Confirm the cart update was communicated (without mouse).
  • Navigate to the cart. Review the cart contents. Remove one item.
  • Proceed to checkout. Complete the shipping address form. Select a shipping method. Enter payment information. Complete the order.

Note any point where you cannot complete an action, cannot determine where focus is, or must resort to using the mouse. Each such point is a keyboard accessibility failure. Combine keyboard testing with screen reader testing for full coverage, and use automated testing tools to catch regressions between manual tests.

Frequently asked questions

What does WCAG 2.1.1 require for keyboard accessibility?
WCAG 2.1.1 (Level A) requires that all functionality is operable via keyboard alone. Every interactive element must be reachable and usable with Tab, Enter, Space and arrow keys. This includes custom dropdowns, modals, carousels, filters and checkout forms.
What is the roving tabindex pattern?
Roving tabindex is a keyboard navigation pattern for groups of related controls like size selectors or color swatches. Only the selected option has tabindex 0 while others have tabindex -1. Arrow keys move between options within the group, and Tab moves focus out of the group entirely.
How should focus trapping work in modals and cart drawers?
When a modal or cart drawer is open, Tab should cycle through only the interactive elements inside it. When it closes, focus must return to the element that triggered it. Use the HTML inert attribute on background content to prevent interaction with the page behind the modal.
How do I test keyboard navigation on an ecommerce store?
Disconnect your mouse and navigate the full purchase flow using only keyboard. Browse to a product, select variants, add to cart, review cart, proceed through checkout and complete payment. Any point where you cannot complete an action or lose track of focus is a keyboard accessibility failure.

Complyko tests your complete purchase flow for keyboard accessibility failures, including cart and checkout flows that automated tools cannot reach. Get a free report.

Get your free scan →