Skip to content
easeweb
Search topics

Hold-to-confirm buttons and other timed key presses

A saved list deletes only if Enter is held for 1.5 seconds or pressed twice in 3, so one quick press from a switch 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

  • Broken 1: then try to delete the list at your own pace. The panel under the lists shows how long the key was held.

  • Broken 2: then try to delete the list at your own pace. The panel shows how long is left to press again.

  • Apply a fix. Press Enter once, quickly, again. Can you delete the list at your own pace?

Broken Can you fix this?

Saved lists

  • Kitchen ideas

    14 items

  • Guest room

    6 items

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Make one ordinary press do the job

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>
What is wrong3 points
  • One press doesn't delete: the only way is to keep a key or a pointer down for 1.5 seconds.
  • The one quick press a switch or speech input sends does nothing: it starts the timer and stops it again straight away.
  • A screen reader in browse mode can't delete the list either: its click is over just as quickly, or never starts the timer at all.
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>
How it is fixed4 steps
  1. Make Delete list an ordinary button that opens a confirmation dialog, named by its question, with showModal(). One click, tap, Enter or Space opens it, and the moment of thought the hold was for is now a question that waits as long as the person needs.
  2. Put autofocus on Keep list. Focus starts there, so a press that repeats keeps the list.
  3. Give the two buttons values in a method="dialog" form, and delete only when the dialog closes with delete. One more press answers it, and after Keep list or Escape the browser returns focus to Delete list.
  4. Once the list is gone, move focus to the heading above the lists, which takes tabindex="-1", instead of letting it fall to the page's body.

This fixes both Befores and passes 2.1.1. How to make the question itself read out is covered in confirmation dialogs that don't read out their question.

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.

How screen readers handle aria-describedby and <dialog>

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.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service