Element.setPointerCapture() makes an element the capture target for future pointer events. Events for that pointer keep targeting the element until releasePointerCapture() or pointerup (MDN). Returns undefined.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.setPointerCapture. Start with this line.
JavaScript
element.setPointerCapture(pointerId)
Call
What it does
element.setPointerCapture(pointerId)
Primary signature.
el.setPointerCapture(...)
Call with the arguments your case needs.
Built into the browser. Call setPointerCapture(...) on an Element — no import required.
On down: attach move handler, then capture the pointer.
On move: read coordinates while capture is active.
On up: remove the handler and call releasePointerCapture.
Why release? Clean stop if you end early; pointerup also ends capture (MDN).
Example 3 — Guard Against NotFoundError
Only capture a live pointerId from an active event.
JavaScript
const el = document.getElementById("pad");
el.addEventListener("pointerdown", (e) => {
try {
el.setPointerCapture(e.pointerId); // OK — active pointer
} catch (err) {
console.log(err.name); // NotFoundError if id was stale
}
});
// Bad: fake id with no active pointer
// el.setPointerCapture(999); → NotFoundError
Use the event’s id.e.pointerId matches an active pointer.
Stale / fake ids throw. MDN: NotFoundError.
Wrap in try/catch if you ever reuse stored ids.
Best practice: call capture only inside the pointer handler.
Compatibility
Browser Support
Element.setPointerCapture() is Baseline Widely available on MDN (across browsers since July 2020). Safe to use in modern drag and pointer UIs.
✓ Baseline Widely available
Element.setPointerCapture()
Pointer capture for drag/slider controls — widely supported.
WideBaseline
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
setPointerCapture()Widely available
Bottom line: Call setPointerCapture(e.pointerId) on pointerdown. Pair with releasePointerCapture / hasPointerCapture. Prefer over deprecated setCapture().
Frequently Asked Questions
It designates an element as the capture target for future pointer events. Subsequent events for that pointer go to the capture element until releasePointerCapture() is called or pointerup fires (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 — typically event.pointerId from pointerdown (MDN).
On pointerdown when starting a drag, slider, or custom control so pointermove and pointerup still reach your element if the pointer leaves its bounds (MDN).
NotFoundError DOMException if pointerId does not match any active pointer (MDN).