The Touch() constructor creates a new Touch object.
On this page
Touch: Touch() constructor
Syntax
js
new Touch(options)
Parameters
-
touchInit -
An object with the following fields:
-
identifier -
A
longvalue, that is the identification number for the touch point. -
target -
A
EventTargetobject, the item at which the touch point started when it was first placed on the surface. clientXOptional-
Defaults to
0, of typedouble, that is the horizontal position of the touch on the client window of user's screen, excluding any scroll offset. clientYOptional-
Defaults to
0, of typedouble, that is the vertical position of the touch on the client window of the user's screen, excluding any scroll offset. screenXOptional-
Defaults to
0, of typedouble, that is the horizontal position of the touch on the user's screen. screenYOptional-
Defaults to
0, of typedouble, that is the vertical position of the touch on the user's screen. pageXOptional-
Defaults to
0, of typedouble, that is the horizontal position of the touch on the client window of user's screen, including any scroll offset. pageYOptional-
Defaults to
0, of typedouble, that is the vertical position of the touch on the client window of the user's screen, including any scroll offset. radiusXOptional-
Defaults to
0, of typefloat, that is the radius of the ellipse which most closely circumscribes the touching area (e.g. finger, stylus) along the axis indicated by rotationAngle, in CSS pixels of the same scale as screenX;0if no value is known. The value must not be negative. radiusYOptional-
Defaults to
0, of typefloat, that is the radius of the ellipse which most closely circumscribes the touching area (e.g. finger, stylus) along the axis perpendicular to that indicated by rotationAngle, in CSS pixels of the same scale as screenY;0if no value is known. The value must not be negative. rotationAngleOptional-
Defaults to
0, of typefloat, that is the angle (in degrees) that the ellipse described by radiusX and radiusY is rotated clockwise about its center;0if no value is known. The value must be greater than or equal to0and less than90. If the ellipse described by radiusX and radiusY is circular, then rotationAngle has no effect. The user agent may use0as the value in this case, or it may use any other value in the allowed range. (For example, the user agent may use the rotationAngle value from the previous touch event, to avoid sudden changes.). forceOptional-
Defaults to
0, of typefloat, that is the relative value of pressure applied, in the range0to1, where0is no pressure, and1is the highest level of pressure the touch device is capable of sensing;0if no value is known. In environments where force is known, the absolute pressure represented by the force attribute, and the sensitivity in levels of pressure, may vary.
-
Specifications
| Specification |
|---|
| Touch Events # dom-touch-constructor |
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 |
See also
TouchEvent, the interface of the objects it constructs.
© 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/Touch