This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

pressure

Summary

The normalized pressure of the pointer input in the range of [0,1], where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively.

Property of dom/PointerEventdom/PointerEvent

Syntax

Note: This property is read-only.

var pressure = event.pressure;

Return Value

Returns an object of type doubledouble

Pressure of the pointer contact in range of 0 to 1.

Examples

The following is an example of a pointermove event handler that outputs the value of the event.pressure property to a text field in a form (frmOutput);

function getPressure(evt){
var theform=document.forms.frmOutput;
theform.txtPressure.value=evt.pressure;
}

Usage

 Could be used for example to control the hue or opacity of a color of a line or shape as it is drawn on screen using a pointer, other than a mouse.

For hardware that does not support pressure, including but not limited to mouse, the value must be 1 when in the active buttons state and 0 otherwise.

Notes

Starting with Internet Explorer 11, this property returns a value of 0.5 for active contact (such as mouse button push) and 0 otherwise on hardware that does not support pressure.

Attributions