PointerEvent: width property
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.
Thewidth read-only property of thePointerEvent interface represents the width of the pointer's contactgeometry along the x-axis, measured in CSS pixels. Depending on the source of thepointer device (such as a finger), for a given pointer, each event may produce adifferent value.
If the input hardware cannot report the contact geometry to the browser, the widthdefaults to1.
In this article
Value
The width of the event's contact area (in CSS pixels).
Examples
This example illustrates using thePointerEvent interface'swidth andheight properties to calculate the contact area.
js
target.addEventListener("pointerdown", (ev) => { // Calculate the contact area const area = ev.width * ev.height;});Specifications
| Specification |
|---|
| Pointer Events> # dom-pointerevent-width> |