{{ APIRef("Touch Events") }}
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 {{ domxref("Touch.radiusX") }}, {{ domxref("Touch.radiusY") }}, and {{ domxref("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_inline}}
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.
Properties
This interface has no parent, and doesn't inherits or implements any other property.
Basic properties
- {{ domxref("Touch.identifier") }} {{readonlyInline}}
- 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. - {{ domxref("Touch.screenX") }} {{readonlyInline}}
- Returns the X coordinate of the touch point relative to the left edge of the screen.
- {{ domxref("Touch.screenY") }} {{readonlyInline}}
- Returns the Y coordinate of the touch point relative to the top edge of the screen.
- {{ domxref("Touch.clientX") }} {{readonlyInline}}
- Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.
- {{ domxref("Touch.clientY") }} {{readonlyInline}}
- Returns the Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset.
- {{ domxref("Touch.pageX") }} {{readonlyInline}}
- 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. - {{ domxref("Touch.pageY") }} {{readonlyInline}}
- 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. - {{ domxref("Touch.target") }} {{readonlyInline}}
- Returns the {{ domxref("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
{{SeeCompatTable}}
- {{ domxref("Touch.radiusX") }} {{readonlyInline}} {{experimental_inline}}
- 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
. - {{ domxref("Touch.radiusY") }} {{readonlyInline}} {{experimental_inline}}
- 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
. - {{ domxref("Touch.rotationAngle") }} {{readonlyInline}} {{experimental_inline}}
- 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.
- {{ domxref("Touch.force") }}{{readonlyInline}} {{experimental_inline}}
- Returns the amount of pressure being applied to the surface by the user, as a
float
between0.0
(no pressure) and1.0
(maximum pressure).
Methods
This interface has no method and no parent, and doesn't inherits or implements any method.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('Touch Events 2', '#touch-interface', 'Touch')}} | {{Spec2('Touch Events 2')}} | Added radiusX , radiusY , rotationAngle , force properties |
{{SpecName('Touch Events', '#touch-interface', 'Touch')}} | {{Spec2('Touch Events')}} | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome("22.0")}} | {{CompatGeckoDesktop("18.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
radiusX , radiusY , rotationAngle , force |
Feature | Android | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("6.0")}} | {{CompatVersionUnknown}} | 11 | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
radiusX , radiusY , rotationAngle , force |
See also
- Touch events
- {{ domxref("TouchList") }}
- {{ domxref("TouchEvent") }}
- {{ domxref("Document.createTouch()") }}