files/en-us/web/api/element/lostpointercapture_event/index.md
{{APIRef("Pointer Events")}}
The lostpointercapture event is fired when a captured pointer is released.
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
addEventListener("lostpointercapture", (event) => { })
onlostpointercapture = (event) => { }
A {{domxref("PointerEvent")}}. Inherits from {{domxref("Event")}}.
{{InheritanceDiagram("PointerEvent")}}
This interface inherits properties from {{domxref("MouseEvent")}} and {{domxref("Event")}}.
PointerEvent.0 to 1, where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively.-1 to 1, where 0 is the neutral position of the control.-90 to 90) between the Y–Z plane and the plane containing both the pointer (e.g., pen stylus) axis and the Y axis.-90 to 90) between the X–Z plane and the plane containing both the pointer (e.g., pen stylus) axis and the X axis.0 to 359.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.
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:
const para = document.querySelector("p");
para.onlostpointercapture = () => {
console.log("I've been released!");
};
para.addEventListener("pointerdown", (event) => {
para.setPointerCapture(event.pointerId);
});
{{Specifications}}
{{Compat}}