Skip to content
easeweb
Search topics

Hold-to-confirm buttons and other timed key presses

A saved list deletes only while Enter is held for 1.5 seconds, or pressed again within 3 seconds, so a single quick press from a switch, speech input or a screen reader does nothing.

WCAG 2.2
SC 2.1.1A
Required by
Section 508 · EN 301 549 (EU)
Broken setTimeout(deleteList, 1500)
The accessibility problem illustrated: Motor:Why won't it delete?
01

The problem

People whose switch, speech input, on-screen keyboard or screen reader sends one quick press can't delete a list, and people who press slowly run out of time.

02

Try it

Tab to the button under Kitchen ideas and press Enter once, quickly, as a switch or speech input would.

Then try to delete the list at your own pace. The panel under the lists shows how long the key was held, or how long is left to press again.

Broken Can you fix this?

Saved lists

  • Kitchen ideas

    14 items

  • Guest room

    6 items

Last press: none yet

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Let one press open a question that waits, or delete with an Undo that stays.

  1. 1No action needs a key held down, or pressed again, within a set time.
  2. 2One quick press of Enter or Space reaches every action, or a confirmation that waits.
  3. 3After deleting or undoing, focus moves to something still on the page.
Before

A button that deletes only while held

<h2>Saved lists</h2><ul>  <li>    <h3>Kitchen ideas</h3>    <p>14 items</p>    <button type="button" id="delete-list" class="hold">      <span class="hold-fill" aria-hidden="true"></span>      Hold to delete    </button>  </li>  …</ul>
After

One press opens a question that waits

<h2 id="lists-heading" tabindex="-1">Saved lists</h2><ul>  <li id="list-kitchen">    <h3>Kitchen ideas</h3>    <p>14 items</p>    <button type="button" id="delete-list">Delete list</button>  </li>  …</ul> <dialog id="confirm-delete" role="alertdialog"  aria-labelledby="confirm-title" aria-describedby="confirm-message">  <form method="dialog">    <h2 id="confirm-title">Delete “Kitchen ideas”?</h2>    <p id="confirm-message">The list and its 14 saved items will be deleted.</p>    <button value="keep" autofocus>Keep list</button>    <button value="delete">Delete list</button>  </form></dialog>

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

04

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Speech input, Screen reader

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after changing the shared button or list component.

Limits

This is a starting pattern, not a guarantee for every application. The snippets leave out the server calls and restoring a list to its place among several. A press and hold made with a mouse or a finger, and long presses that open menus, are covered from the pointer's side in right-click, long-press and swipe actions with no button. Test the complete journey with a keyboard, a switch, speech input and your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work