Skip to content
easeweb
Search topics

Buttons that act on press and can't be cancelled

The button runs its action on pointerdown, so a press that lands on it by mistake takes effect at once, and sliding off before letting go can't stop it.

WCAG 2.2
SC 2.5.2A· new in 2.1
Required by
EN 301 549 (EU)
Broken addEventListener('pointerdown', addToBasket)
The accessibility problem illustrated: Reach, strength:I slid off, so why was it added?
01

The problem

People whose press lands on the wrong button can't take it back by sliding off before they let go.

02

Try it

Press and hold Add to basket, and watch when the item goes in. Then slide off before you let go.

Touching a button is not deciding; letting go is. That gap is how anyone who touches the wrong button, or only meant to scroll, changes their mind. The panel under the shop shows whether this one waits. On a phone, also scroll the list starting on a button.

Broken Can you fix this?

Kitchen linen Basket (0)
  • Linen tea towel
  • Cotton apron
  • Oak chopping board
  • Enamel mug
On almost every button, touching it is not yet a decision: letting go is. Until then, you can slide off if you touched the wrong one. Press and hold a button to see when this shop decides.

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Move the action to click, and let the press do nothing but show that it's pressed.

  1. 1Run actions on release over the control, never on press.
  2. 2Sliding off before letting go cancels, and a scroll never counts as a press.
  3. 3A down listener may show a pressed look, keep focus or start a drag, but never complete the action.
Before The action on pointerdown
<button type="button" class="add">Add to basket</button>
After The action on click
<button type="button" class="add">Add to basket</button>

Why this fix: Use native HTML first

Fixing this with an AI coding assistant? Get this guide as Markdown

04

Verify the fix

5 checks.

Test with: Mouse, Touch, Keyboard, 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 the shared button or card component changes.

Limits

This is a starting pattern, not a guarantee for every application. Some controls must act on the press because that is what they are, such as the keys of an on-screen keyboard or a musical instrument; WCAG treats those as essential. A small button can still be missed in the first place: tap targets too small and too close together covers its size. Test the complete journey on real touch devices as well as with a mouse.

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