W3cubDocs

/Web APIs

Touch

The Touch interface represents a single contact point on a touch-sensitive device. The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad.

The Touch.radiusX, Touch.radiusY, and Touch.rotationAngle describe the area of contact between the user and the screen, the touch area. This can be helpful when dealing with imprecise pointing devices such as fingers. These values are set to describe an ellipse that as closely as possible matches the entire area of contact (such as the user's fingertip). Experimental

Note: Many of the properties' values are hardware-dependent; for example, if the device doesn't have a way to detect the amount of pressure placed on the surface, the force value will always be 0. This may also be the case for radiusX and radiusY; if the hardware reports only a single point, these values will be 1.

Constructor

Touch()

Creates a Touch object.

Instance properties

This interface has no parent, and doesn't inherit or implement other properties.

Basic properties

Touch.identifier Read only

Returns a unique identifier for this Touch object. A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. This lets you ensure that you're tracking the same touch all the time.

Touch.screenX Read only

Returns the X coordinate of the touch point relative to the left edge of the screen.

Touch.screenY Read only

Returns the Y coordinate of the touch point relative to the top edge of the screen.

Touch.clientX Read only

Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.

Touch.clientY Read only

Returns the Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset.

Touch.pageX Read only

Returns the X coordinate of the touch point relative to the left edge of the document. Unlike clientX, this value includes the horizontal scroll offset, if any.

Touch.pageY Read only

Returns the Y coordinate of the touch point relative to the top of the document. Unlike clientY, this value includes the vertical scroll offset, if any.

Touch.target Read only

Returns the Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element or even been removed from the document.

Touch area

Touch.radiusX Read only

Returns the X radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenX.

Touch.radiusY Read only

Returns the Y radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenY.

Touch.rotationAngle Read only

Returns the angle (in degrees) that the ellipse described by radiusX and radiusY must be rotated, clockwise, to most accurately cover the area of contact between the user and the surface.

Touch.force Read only

Returns the amount of pressure being applied to the surface by the user, as a float between 0.0 (no pressure) and 1.0 (maximum pressure).

Instance methods

This interface has no methods and no parent, and doesn't inherit or implement any methods.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
Touch 48 79
52This interface is only exposed if a touch input device is detected.
No 35 No 48 48 6 35 ≤3 5.0
Touch 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 ≤3 1.5
altitudeAngle No No No No No No No No No No 10 No
azimuthAngle No No No No No No No No No No 10 No
clientX 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
clientY 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
force 3822–47 ≤79
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 2515–34 No 384.4–47 3825–47 6 2514–34 10 3.01.5–5.0
identifier 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
pageX 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
pageY 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
radiusX 3822–47 ≤79
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 2515–34 No 384.4–47 3825–47 6 2514–34 10 3.01.5–5.0
radiusY 3822–47 ≤79
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 2515–34 No 384.4–47 3825–47 6 2514–34 10 3.01.5–5.0
rotationAngle 4322–47 ≤79
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 3015–34 No 434.4–47 4325–47 6 3014–34 10 4.01.5–5.0
screenX 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
screenY 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
target 22 ≤18
52This interface is only exposed if a touch input device is detected.
18–24Removed in bug 888304 due to web compatibility issues.
No 15 No 4.4 25 6 14 10 1.5
touchType No No No No No No No No No No 10 No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Touch