Element: lostpointercapture event

Baseline
Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

The lostpointercapture event is fired when a captured pointer is released.

Syntax

Use the event name in addEventListener():

js
addEventListener("lostpointercapture", (event) => { })

Alternatively, assign to the event handler property of the interface:

js
onlostpointercapture = (event) => { }

Event type

A PointerEvent. Inherits from Event.

Event UIEvent MouseEvent PointerEvent

Examples

This example listens for the lostpointercapture event for an element, and captures the pointer for the element on pointerdown. When the user subsequently releases the pointer, the lostpointercapture event will be fired.

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

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

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

The same example, but using the onlostpointercapture event handler property (but note that this replaces other event listeners added using onlostpointercapture, if any):

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

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

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

Specifications

Specification
Pointer Events
# lostpointercapture
Pointer Events
# dom-globaleventhandlers-onlostpointercapture

Browser compatibility

See also