Element.setPointerCapture() is an instance method that requests pointer capture for a given pointerId. Learn MDN’s horizontal slider demo, why capture keeps events flowing when the pointer leaves an element, how to pair with releasePointerCapture() and hasPointerCapture(), and five try-it labs aligned with MDN.
01
Kind
Instance method
02
Returns
undefined
03
Arg
pointerId
04
Action
Request capture
05
Events
Pointer
06
Status
Baseline widely
Fundamentals
Introduction
Custom sliders, drag handles, and drawing tools need pointer events even when the user moves the mouse, finger, or pen outside the element. Without pointer capture, pointermove and pointerup may stop firing on your control once the pointer leaves its bounds.
element.setPointerCapture(pointerId) tells the browser: send all future events for this pointer to this element until capture is released (MDN). Call it on pointerdown, then call releasePointerCapture(pointerId) on pointerup or pointercancel.
💡
MDN slider pattern
Set capture when the user presses down, attach pointermove to slide the element, and release capture on pointerup. Add touch-action: none in CSS for smooth touch dragging.
Element.setPointerCapture() is Baseline Widely available (MDN: across browsers since July 2020). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Widely available
Element.setPointerCapture()
Request pointer capture for a pointerId — essential for drag, slider, and drawing UIs.
BaselineWidely available
Google ChromeSupported · Desktop & Mobile
Yes
Microsoft EdgeSupported · Chromium
Yes
Mozilla FirefoxSupported · Desktop & Mobile
Yes
Apple SafariSupported · macOS & iOS
Yes
OperaSupported · Modern versions
Yes
Internet ExplorerNot supported
No
setPointerCapture()Excellent
Bottom line: Use setPointerCapture() on pointerdown and releasePointerCapture() on pointerup. Add touch-action: none for touch sliders. Prefer over deprecated setCapture().
Wrap Up
Conclusion
Element.setPointerCapture() keeps pointer events on your element during drags and sliders. MDN’s pattern: capture on pointerdown, handle pointermove, release on pointerup.
Five things to remember about Element.setPointerCapture()
Request capture — keep pointer events during drag and slider interactions.
5
Core concepts
📝01
Returns
undefined
API
👆02
Arg
pointerId
Event
🎯03
Capture
request
Route
📈04
Pair
release
Cleanup
🌐05
Support
baseline
Jul 2020
❓ Frequently Asked Questions
It designates an element as the capture target for future pointer events. Subsequent events for that pointer are targeted at the capture element until capture is released via releasePointerCapture() or pointerup (MDN).
No. MDN marks Element.setPointerCapture() as Baseline Widely available (across browsers since July 2020). It is not Deprecated, Experimental, or Non-standard.
undefined. There is no return value (MDN).
The pointerId from a PointerEvent object — typically event.pointerId from pointerdown, pointermove, or pointerup (MDN).
On pointerdown when starting a drag, slider, or custom control so pointermove and pointerup still reach your element even if the pointer leaves its bounds (MDN).
MDN: NotFoundError if pointerId does not match any active pointer.
Did you know?
MDN recommends setPointerCapture() as the modern replacement for the deprecated Gecko-only setCapture() method. Pointer capture works across mouse, touch, and pen with the same pointerId API.