The pointercancel event fires when the browser cancels an active pointer. Learn addEventListener vs onpointercancel, common cancel causes, the follow-up pointerout / pointerleave sequence, gesture cleanup, and five try-it labs.
01
Kind
Instance event
02
Type
PointerEvent
03
When
Pointer cancelled
04
Handler
onpointercancel
05
Follow-up
pointerout · pointerleave
06
Status
Baseline widely available
Fundamentals
Introduction
Not every pointer session ends with a clean pointerup. The OS or browser may steal the gesture—home button, app switcher, orientation change, palm rejection, viewport pan/zoom, or touch-action scrolling.
pointercancel is the signal: “This pointer will not continue.” Abort drag/draw state immediately so your UI does not stay stuck in a pressed or dragging mode.
💡
Beginner tip
After pointercancel, MDN notes the browser also fires pointerout then pointerleave. Treat cancel as the end of the active pointer, then expect those leave events.
Concept
Understanding pointercancel
An instance event that answers: “Did the browser cancel this pointer?”
Fires when more pointer events are unlikely, or the pointer starts panning/zooming/scrolling the viewport after pointerdown.
PointerEvent — pointerId, pointerType, isPrimary, and more.
Handler — onpointercancel or addEventListener("pointercancel", ...).
Follow-up — pointerout then pointerleave.
Baseline Widely available on MDN (since July 2020).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
A PointerEvent (inherits from MouseEvent and Event).
Handy properties
Property
Meaning
pointerId
Unique id for this pointer stream
pointerType
Device kind: mouse, pen, touch, etc.
isPrimary
Whether this is the primary pointer of that type
pressure / width / height
Contact geometry and pressure when available
Triggers
⚡ When pointercancel Fires
MDN lists common situations that can trigger it:
Hardware / OS interrupts (app switcher, mobile Home button).
Screen orientation changes while the pointer is active.
Accidental input detection (for example palm rejection with a stylus).
touch-action CSS preventing the input from continuing (browser takes over for pan/zoom).
Too many simultaneous pointers—the browser may cancel existing ones.
Compare
⚖️ pointercancel vs Related Events
Event
Typical meaning
pointercancel
Browser aborted this pointer; stop the gesture
pointerup
Normal release of the pointer
pointerout / pointerleave
Leave sequence that also follows cancel (per MDN)
lostpointercapture
Capture ended (may accompany cancel if you used capture)
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Listen
el.addEventListener("pointercancel", fn)
Handler property
el.onpointercancel = fn
Identify pointer
event.pointerId, event.pointerType
Clean up drag
Clear classes / flags on cancel andpointerup
After cancel
Expect pointerout then pointerleave
MDN status
Baseline Widely available (Jul 2020)
Snapshot
🔍 At a Glance
Four facts to remember about pointercancel.
Event type
PointerEvent
MouseEvent + more
Means
aborted
Not a normal up
Then
out → leave
MDN sequence
Baseline
yes
Since Jul 2020
Hands-On
Examples Gallery
Examples follow MDN Element: pointercancel event. On desktop, cancel is harder to trigger than pointerup—labs also show how to wire cleanup so you are ready when it does fire (touch devices / pan gestures).
pointercancel is marked Baseline Widely available on MDN (since July 2020). Logos use the shared browser-image-sprite.png sprite from this project. Pointer Events are the modern unified mouse/touch/pen model across engines.
✓ Baseline · Widely available
Element pointercancel
Fires when the browser aborts a pointer; clear gesture state, then expect pointerout / pointerleave.
FullWidely available
Google ChromeFull support
Yes
Mozilla FirefoxFull support
Yes
Apple SafariFull support
Yes
Microsoft EdgeFull support
Yes
OperaFull support
Yes
Internet ExplorerPointer Events (legacy IE11 path)
Partial
pointercancelBaseline
Bottom line: Wire cancel cleanup next to pointerup for robust drag and drawing UIs on touch devices.
Wrap Up
Conclusion
pointercancel is the abort path for Pointer Events. Listen beside pointerup, clear session state by pointerId, and remember the follow-up pointerout / pointerleave sequence.
Clear drag/draw state on both pointerup and pointercancel
Key multi-touch sessions by pointerId
Use touch-action intentionally when you need exclusive gestures
Pair capture APIs with lostpointercapture cleanup
Prefer addEventListener in production code
❌ Don’t
Assume every gesture ends with pointerup
Leave pressed / dragging CSS classes after a cancel
Ignore palm rejection and multi-pointer cancel paths on touch devices
Forget that cancel is followed by out/leave
Overwrite onpointercancel if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about pointercancel
Pointer aborted—clear gesture state before the leave sequence.
5
Core concepts
📱01
On cancel
browser aborted
Trigger
📄02
PointerEvent
pointerId · type
API
🔄03
Cleanup
with pointerup
Pattern
👆04
Then leave
out → leave
Sequence
🎯05
Baseline
since Jul 2020
Status
❓ Frequently Asked Questions
It fires when the browser decides there will likely be no more events for that pointer, or when after pointerdown the pointer is used to pan, zoom, or scroll the viewport. Use it to abort in-progress gestures cleanly.
No. MDN marks Element pointercancel as Baseline Widely available (since July 2020). It is not Deprecated, Experimental, or Non-standard.
A PointerEvent (inherits from MouseEvent and Event). Useful fields include pointerId, pointerType, isPrimary, pressure, and width/height.
MDN notes the browser also sends pointerout followed by pointerleave after pointercancel.
Whenever you start a drag, draw, or press-and-hold session on pointerdown. Cancel resets UI if the OS steals the gesture (home button, app switcher, orientation change, palm rejection, touch-action scroll, too many pointers).
If you used setPointerCapture, a cancel path often ends capture and can fire lostpointercapture too. Always clear drag state on pointercancel and/or lostpointercapture so the UI never sticks.
Did you know?
Even after a pointercancel, MDN says the browser still dispatches pointerout and pointerleave. That means leave handlers can still run—so keep cancel cleanup idempotent (safe to call twice).