Firefox Tomorrow

web api event

Element: gotpointercapture event

View on MDN ↗

The gotpointercapture event is fired when an element captures a pointer using setPointerCapture().

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("gotpointercapture", (event) => { })

ongotpointercapture = (event) => { }

Event type

A PointerEvent. Inherits from Event.

Examples

This example gets a <p> element and listens for the gotpointercapture event. It then calls setPointerCapture() on the element on a pointerdown event, which will trigger gotpointercapture.

const para = document.querySelector("p");

para.addEventListener("gotpointercapture", () => {
  console.log("I've been captured!");
});

para.addEventListener("pointerdown", (event) => {
  para.setPointerCapture(event.pointerId);
});

The same example, using the ongotpointercapture event handler property:

const para = document.querySelector("p");

para.ongotpointercapture = () => {
  console.log("I've been captured!");
};

para.addEventListener("pointerdown", (event) => {
  para.setPointerCapture(event.pointerId);
});

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also