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 .
var pressure = pointerEvent.pressure;
pressure
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);
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. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 55.0 | (Yes) | (Yes) [1] | 10 | 42 | No support |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|---|
Basic support | No support | 55.0 | (Yes) | No support | No support | 10 | 42 | No support | 55.0 |
[1] This feature is currently hidden behind a flag; to enable it and experiment, set the dom.w3c_pointer_events.enabled
preference to true
in about:config
.
© 2005–2017 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