The gotpointercapture event fires when an element captures a pointer with setPointerCapture(). Learn addEventListener vs ongotpointercapture, pointerId, the lostpointercapture pair, drag capture patterns, and five try-it labs.
01
Kind
Instance event
02
Type
PointerEvent
03
When
After setPointerCapture()
04
Handler
ongotpointercapture
05
Pair
lostpointercapture
06
Status
Baseline widely available
Fundamentals
Introduction
Pointer capture lets an element keep receiving events for a specific pointer even when the pointer leaves that element’s hit area—perfect for sliders, drag handles, and canvas drawing.
When you call setPointerCapture(pointerId) and capture succeeds, the browser fires gotpointercapture on the capturing element. Pair it with lostpointercapture to know when capture ends.
💡
Beginner tip
Capture usually starts inside a pointerdown handler while a button/touch is active. Use event.pointerId from that event when calling setPointerCapture. Set touch-action: none on drag surfaces so the browser does not steal the gesture for scrolling.
Concept
Understanding gotpointercapture
An instance event that answers: “Did this element just become the capture target for a pointer?”
Fires after a successful setPointerCapture(pointerId).
PointerEvent — includes pointerId, pointerType, and more.
Handler — ongotpointercapture or addEventListener("gotpointercapture", ...).
Pair — lostpointercapture when capture is released.
Related APIs — setPointerCapture, releasePointerCapture, hasPointerCapture.
Baseline Widely available on MDN.
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
gotpointercapture is marked Baseline Widely available on MDN. Logos use the shared browser-image-sprite.png sprite from this project. Pointer capture is part of the modern Pointer Events model across engines.
✓ Baseline · Widely available
Element gotpointercapture
Fires when setPointerCapture() succeeds; pair with lostpointercapture for drag sessions.
FullWidely available
Google Chrome57+
Yes
Mozilla Firefox59+
Yes
Apple Safari13+
Yes
Microsoft Edge17+
Yes
Opera44+
Yes
Internet ExplorerNo modern Pointer Events
No
gotpointercaptureBaseline
Bottom line: Safe to use for modern drag UX. Always release capture cleanly and test touch + mouse paths.
Wrap Up
Conclusion
gotpointercapture tells you that setPointerCapture worked. Use it to enter a drag session, keep listening for moves, and clean up on lostpointercapture.
Call setPointerCapture from pointerdown with event.pointerId
Listen for gotpointercapture / lostpointercapture as a pair
Use hasPointerCapture before releasing
Set touch-action: none on drag surfaces
Prefer addEventListener for production code
❌ Don’t
Assume capture without waiting for gotpointercapture (or checking hasPointerCapture)
Forget to release / handle pointerup and pointercancel
Move the element in the DOM and expect old capture to stick without re-calling
Ignore touch scrolling interference on mobile
Overwrite ongotpointercapture if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about gotpointercapture
Capture confirmed—keep pointer events until release.
5
Core concepts
📱01
After setPointerCapture
capture confirmed
Trigger
📄02
PointerEvent
pointerId · type
API
👆03
Drag UX
moves keep coming
Why
🔄04
lostpointercapture
session closed
Pair
🎯05
Baseline
widely available
Status
❓ Frequently Asked Questions
It fires on an element after that element successfully captures a pointer with setPointerCapture(pointerId). From then on, subsequent events for that pointer are retargeted to the capturing element until capture is released.
No. MDN marks Element gotpointercapture as Baseline Widely available. It is not Deprecated, Experimental, or Non-standard.
A PointerEvent (inherits from MouseEvent and Event). Handy fields include pointerId, pointerType, and isPrimary.
Usually call element.setPointerCapture(event.pointerId) inside a pointerdown handler while the pointer is in an active buttons state. When capture succeeds, gotpointercapture fires.
lostpointercapture fires when capture is released — via releasePointerCapture(), pointerup, pointercancel, or similar release paths.
So a drag, slider, or drawing surface keeps receiving pointermove events even if the pointer leaves the element’s bounds.
Did you know?
While pointer capture is active, pointerover / pointerenter / pointerleave / pointerout generally do not fire for hit-testing changes—events are retargeted to the capturing element.