On this page
What this issue is
A keyboard trap means a person using only the keyboard moves focus into a component and cannot move it out again. It fails WCAG 2.1.2 (No Keyboard Trap), a Level A requirement. Focus is the highlighted element that receives your key presses.
Not every focus lock is a bug. A modal dialog should keep Tab inside the dialog while it is open. It becomes a trap when there is no way to close it with the keyboard, or when focus loops inside something that is not meant to hold it.
| Situation | Tab stays inside? | Way out by keyboard? | Verdict |
|---|---|---|---|
| Modal with close button and Escape support | Yes | Yes | Correct |
| Modal with no close button reachable by Tab, no Escape | Yes | No | Trap |
| Embedded iframe form or chat widget that swallows Tab | Yes | No | Trap |
| Date picker or video player that ignores Tab and Escape | Yes | No | Trap |
| Popup that closes visually but leaves an invisible focus loop | Yes | No | Trap |
Why it costs you leads or sales
People who use a keyboard, a switch device or a screen reader cannot get past the trap. They cannot submit your lead form, reach the checkout button or close the newsletter popup that covers the page. Many of them simply leave.
Power users who prefer the keyboard hit the same wall. Traps also tend to appear on your highest-value steps: exit-intent popups, cookie banners, booking widgets, embedded forms and live chat.
- Landing pageVisitor tabs through the page
- Popup opensOffer modal appears
- Focus trappedTab loops, no close by keyboard
- FormNever reached
- Lead or saleVisitor leaves
A visitor using only the keyboard gets stuck in a popup and never reaches the form.
Example: of 100 keyboard-only visitors who open a popup, how many reach the form with and without a trap. Numbers are illustrative.
How to check if your site has it
Put the mouse aside
Open the page and use only the keyboard. Press Tab to move forward and Shift+Tab to move back.
Open every popup and widget
Trigger the modal, cookie banner, exit-intent offer, chat bubble and booking widget with Enter or Space on their buttons.
Try to leave with Escape
Press Escape. A modal should close. If it does not, press Tab repeatedly and look for a close button that receives a visible focus ring.
Check where focus goes next
After closing, focus should return to the button that opened the modal. If it jumps to the top of the page or disappears, see PRF-315.
Test embedded iframes
Tab into any embedded form, map, video or chat. Make sure Tab eventually moves focus out to the next element on the page.
Repeat on mobile layout
Narrow your browser window or use a device with a keyboard attached. Responsive popups often have different markup.
How to fix it
The goal is simple: whatever opens with the keyboard must close with the keyboard, and focus must be able to leave. For modals, keep focus inside while open, then release it on close.
Identify the source
Disable popup, chat and cookie plugins one at a time on a staging copy and retest with Tab to find which one traps focus.
Check plugin settings
In the popup plugin, enable options such as close on Escape and show a close button. Update the plugin, as accessibility fixes are common in newer versions.
Replace if needed
If the plugin cannot be fixed, switch to one that uses a proper dialog and ask the vendor about WCAG 2.1.2.
Test the theme first
Preview an unmodified Dawn or other current theme. If it works there, your customised theme or an app is the cause.
Disable apps one by one
Turn off popup, review, chat and upsell apps in the theme editor App embeds section and retest.
Fix theme code
If your theme drawer or modal is custom, add Escape handling and a focusable close button using the code below.
Find injected popups
In Tags, look for Custom HTML tags that inject modals or widgets. Pause them in Preview mode and retest.
Edit the injected code
Add Escape-key closing and a real button with an accessible name to the tag, then publish a new version.
Check interactions
Modals built from interactions often have no keyboard support. Make the close control a real Button or Link block, not a Div.
Add custom code
Add the Escape handler from the snippet below in Page settings, Before body tag, adjusting the selectors to your class names.
Review popups and forms
In the funnel or website builder, check popup elements and embedded forms or calendars. Enable the close icon and close on overlay or Escape if the option is available.
Test the embedded iframe
If a calendar or form iframe swallows Tab, try the direct-link version or contact support, since you cannot edit the iframe content.
Use built-in lightboxes
Wix lightboxes include a close button. Make sure it is not deleted or hidden, and that it is not the only way out on custom elements.
Check third-party apps
Test chat and booking apps from the App Market with keyboard only. Remove or replace the ones that trap focus.
Test popups and announcement bars
Open Pop-Up settings for each page and confirm the close button shows and works with Enter and Escape.
Check code injection
Review Settings, Advanced, Code Injection for third-party widgets and retest after removing each.
Use the native dialog element
The HTML dialog element opened with showModal() handles Escape, focus containment and focus return for you.
Or add handlers to a custom modal
Add role=dialog, aria-modal, a close button, an Escape handler and focus return, as shown below.
<button id="open-offer">Get the offer</button>
<dialog id="offer" aria-labelledby="offer-title">
<h2 id="offer-title">Get 10% off</h2>
<form method="dialog">
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email">
<button type="submit">Send</button>
<button type="submit" value="cancel" formnovalidate>Close</button>
</form>
</dialog>
<script>
const dlg = document.getElementById('offer');
document.getElementById('open-offer').addEventListener('click', () => dlg.showModal());
</script>const modal = document.querySelector('#my-modal');
const closeBtn = modal.querySelector('.close');
let opener = null;
function openModal(trigger) {
opener = trigger;
modal.hidden = false;
closeBtn.focus();
}
function closeModal() {
modal.hidden = true;
if (opener) opener.focus();
}
modal.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeModal();
return;
}
if (e.key !== 'Tab') return;
const items = modal.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"])');
const first = items[0];
const last = items[items.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
});
closeBtn.addEventListener('click', closeModal);How to confirm it's fixed
- Every popup, drawer and widget opens with Enter or Space.
- Escape closes each modal.
- A visible close button can be reached with Tab and activated with Enter.
- Tab and Shift+Tab move through the modal in a logical order without leaving it while open.
- After closing, focus returns to the element that opened the modal.
- Embedded iframes release focus to the next element on the page.
- A screen reader announces the dialog title when it opens (try NVDA, VoiceOver or TalkBack).
- The form inside the modal can be submitted using only the keyboard.
How to prevent it happening again
Traps usually return when someone installs a new popup, chat or booking tool, or updates a theme. Add a keyboard test to your release routine.
- Tab through the page and every popup after each plugin, app or theme update.
- Prefer the native dialog element or a well-maintained, accessibility-tested component.
- Ask vendors of chat and booking widgets whether they meet WCAG 2.1.2 before you install.
- Run an automated accessibility scan such as axe DevTools or Lighthouse, then follow up by hand, since automated tools miss many traps.
- Include keyboard-only checks in your QA list for every new campaign popup or landing page.
How FunnelGuard handles this
FunnelGuard does not check for keyboard traps yet. It is a possible future check, so you should not rely on it for this issue today.
What FunnelGuard does run is your real customer journeys on a schedule: it fills in lead forms, goes through checkouts and booking steps, and checks the tracking hits and whether test leads reach your inbox and CRM. If a broken popup or widget stops that robot from completing a journey, you will see the journey fail, with a screenshot and a likely cause. That is not the same as detecting a keyboard trap, because the robot is not testing keyboard navigation.
To watch for traps, use the manual Tab test above after every change, and run axe DevTools or Lighthouse in your browser. You can also start with the free FunnelGuard plan (1 site, 2 journeys, daily checks) to be told when a key journey stops working.
Questions people ask
What is a keyboard trap in accessibility?
A keyboard trap is when a person using only the keyboard can move focus into a component, such as a modal or widget, but cannot move it out again. It fails WCAG 2.1.2 (No Keyboard Trap), a Level A requirement. Users are stuck unless they use a mouse.
Why can't I tab out of a popup on my website?
The popup probably has no close button that can receive focus, ignores the Escape key, or runs a script that sends focus back inside whenever you press Tab. Check the popup plugin or custom code for Escape handling and a real button as the close control.
Is it a keyboard trap if Tab stays inside a modal?
Not if the modal can be closed with the keyboard. Keeping Tab inside an open modal dialog is expected behaviour. It is only a trap when there is no keyboard way out, such as Escape or a focusable close button.
How do I test for a keyboard trap?
Use only the keyboard. Press Tab and Shift+Tab through the page, open each popup, chat and embedded form, then try Escape and the close button. Confirm that focus can leave every component and returns to the opener when the modal closes.
How do I fix a chat widget that traps keyboard focus?
Check for an update or accessibility setting from the chat vendor, since you usually cannot edit their iframe. If it still traps focus, report it to the vendor or switch to a widget that lets Tab and Escape move focus out.
Do accessibility scanners find keyboard traps?
Only partly. Tools like axe and Lighthouse catch many issues but cannot reliably detect traps that depend on how a script handles keys. A manual Tab test is still needed.
Does FunnelGuard detect keyboard traps?
No. FunnelGuard does not check for keyboard traps yet, though it is a possible future check. It does run your real forms and checkouts on a schedule, so a popup that blocks the journey would show up as a failed journey.
Related issues
- PRF-313Form cannot be completed with keyboard onlyFix guide
- PRF-315Focus not moved into opened modal / not returned on closeFix guide
- PRF-311Focus outline removed (outline:none)Fix guide
- PRF-314Illogical focus orderFix guide
- PRF-322Buttons made from divs without role/keyboard supportFix guide
- PRF-324Icon-only buttons without accessible namesFix guide