pressure 只读特性在 PointerEvent interface indicates the normalized pressure of the pointer input.

句法

var pressure = pointerEvent.pressure;
					

返回值

pressure
The normalized pressure of the pointer input in the range of 0 to 1 , inclusive, where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. For hardware that does not support pressure, such as a mouse, the value is 0.5 when the pointer is active buttons state and 0 否则。

范例

In this snippet, when a pointerdown event is fired, different functions are called depending on the value of the event's pressure 特性。

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

规范

规范 状态 注释
指针事件 – 2 级
The definition of 'pressure' in that specification.
推荐 非稳定版本。
指针事件
The definition of 'pressure' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
pressure Chrome 55 Edge 12 Firefox 59
59
Disabled ). To change preferences in Firefox, visit
IE 11
11
部分支持 10
Returns 0 instead of 0.5 on hardware that doesn't support pressure.
Opera 42 Safari 13 WebView Android 55 Chrome Android 55 Firefox Android 41 Opera Android 42 Safari iOS 13 Samsung Internet Android 6.0

图例

完整支持

完整支持

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: