W3cubDocs

/DOM

PointerEvent.pressure

The normalized pressure of the pointer input in the range of 0 to 1, where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. For hardware that does not support pressure, including but not limited to mouse, the value MUST be 0.5 when the pointer is active and 0 otherwise.

This property is Read only .

Syntax

var pressure = pointerEvent.pressure;

Return value

pressure
The amount of pressure applied to the pointer.

Example

This example illustrates using the pressure property.

When a pointerdown event is fired, different functions are called depending on the value of the event's pressure property.

someElement.addEventListener('pointerdown', function(ev) {
   if (ev.pressure == 0) {
     // No pressure
     process_no_pressure(ev);
   } else if (ev.pressure == 1) {
     // Maximum pressure
     process_max_pressure(ev);
   } else {
     // Default
     process_pressure(ev);
   }
 }, false);

Specifications

Specification Status Comment
Pointer Events – Level 2
The definition of 'pressure' in that specification.
Working Draft Non-stable version.
Pointer Events
The definition of 'pressure' in that specification.
Recommendation Initial definition.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Returns 0 instead of 0.5 on hardware that doesn't support pressure.
42 No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure