# Pointer Cancellation: Act on Release, Not on Press

Source: https://allyway.ai/glossary/pointer-cancellation

Pointer Cancellation is WCAG success criterion 2.5.2 (Level A). For functions operated with a single pointer, the down-event does not trigger the function, or completion on the up-event can be aborted or undone, or the up-event reverses it, unless the down-event is essential.

Pointer cancellation is the chance to change your mind after pressing the wrong button: you press, notice the mistake, slide your finger or mouse away and release – and nothing happens. WCAG 2.5.2 protects that chance by asking that actions run when the pointer is released, not the moment it touches down. It prevents accidental purchases, deletions and page changes.

## What it means

[WCAG 2.5.2 Pointer Cancellation](https://www.w3.org/WAI/WCAG22/Understanding/pointer-cancellation.html) is a Level A criterion. For functionality that can be operated with a single pointer, at least one of four conditions is true:

| Condition | What it means |
|---|---|
| No down-event | The down-event (e.g. `mousedown`, `touchstart`) does not execute any part of the function |
| Abort or undo | The function completes on the up-event (`mouseup`, `touchend`, `click`), and there is a way to abort before completion or undo afterwards |
| Up reversal | The up-event reverses any outcome of the preceding down-event |
| Essential | Completing the function on the down-event is essential |

Functions that emulate a keyboard or numeric keypad key press count as essential, so an on-screen piano or keyboard may react on press. The rule covers content that interprets pointer actions, not the controls of the browser or assistive technology.

W3C names the benefit: all users can recover from hitting the wrong target, and people with visual, motor or cognitive disabilities trigger fewer actions by accident – and are less disoriented by unexpected changes of context.

> **Tip:** > **Native controls already do it right**
> A `<button>` or a link fires its `click` event on release, and only if the pointer is still on it. If you use these elements and the `click` event, you meet 2.5.2 without extra work. Problems start with custom `mousedown` or `touchstart` handlers.

## Examples

```html title="Example"
<!-- Bad: the order is placed the moment the button is pressed -->
<div role="button" tabindex="0" onmousedown="placeOrder()">Buy now</div>

<!-- Good: a native button reacts on release, sliding off cancels -->
<button type="button" onclick="placeOrder()">Buy now</button>

<!-- Good: press and hold to preview, releasing hides it again (up reversal) -->
<button type="button" id="peek">Show password</button>
<script>
  const peek = document.getElementById('peek');
  peek.addEventListener('pointerdown', () => showPassword(true));
  peek.addEventListener('pointerup', () => showPassword(false));
  peek.addEventListener('pointerleave', () => showPassword(false));
</script>
```

The press-and-hold preview follows a W3C example: what appears on press disappears again on release. For drag and drop, W3C shows the abort route: an item dropped outside a valid target goes back to where it was. More on that in [dragging movements](https://allyway.ai/glossary/dragging-movements).

**Do:** Do

Use native buttons and links with the `click` event, let drag and drop snap back when the item is released outside a target, add an "Undo" for actions that cannot wait, and give buttons enough [target size](https://allyway.ai/glossary/target-size) to hit them in the first place.

**Don't:** Don't

Trigger purchases, deletions, navigation or form submission on `mousedown`, `touchstart` or `pointerdown`, or open a menu on press that also selects the item under the pointer.

## How to check pointer cancellation



## Questions

Q: What is the difference between a down-event and an up-event?
A: The down-event happens when the pointer is pressed, such as `mousedown` or `touchstart`. The up-event happens when it is released, such as `mouseup` or `touchend`. WCAG 2.5.2 wants functions to complete on the up-event.

Q: Does the click event meet WCAG 2.5.2?
A: Yes, in practice. The `click` event of native buttons and links fires on release and only when the pointer is still on the element, so sliding away cancels it.

Q: Are press-and-hold actions allowed?
A: Yes, if releasing reverses what pressing did – for example a preview that shows while the pointer is down and hides on release. W3C calls this up reversal.

Q: When may a function trigger on press?
A: Only when it is essential, such as an on-screen keyboard or piano that imitates a key press. W3C counts emulating a keyboard or numeric keypad key press as essential.
