The Event()
constructor creates a new TouchEvent
.
TouchEvent()
Syntax
new TouchEvent(typeArg, touchEventInit);
Values
- typeArg
-
Is a
DOMString
representing the name of the event. - touchEventInit Optional
-
Is a Touch
EventInit
dictionary, having the following fields:-
"touches"
, optional and defaulting to[]
, of typeTouch[]
, that is a list of objects for every point of contact currently touching the surface. -
"targetTouches"
, optional and defaulting to[]
, of typeTouch[]
, that is a list of objects for every point of contact that is touching the surface and started on the element that is the target of the current event. -
"changedTouches"
, optional and defaulting to[]
, of typeTouch[]
, that is a list of objects for every point of contact which contributed to the event. -
"ctrlKey"
, optional and defaulting tofalse
, a boolean value that indicates if the ctrl key was simultaneously pressed. -
"shiftKey"
, optional and defaulting tofalse
, a boolean value that indicates if the shift key was simultaneously pressed. -
"altKey"
, optional and defaulting tofalse
, a boolean value that indicates if the alt key was simultaneously pressed. -
"metaKey"
, optional and defaulting tofalse
, a boolean value that indicates if the meta key was simultaneously pressed.
The Touch
EventInit
dictionary also accepts fields fromUIEventInit
and fromEventInit
dictionaries. -
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 | |
TouchEvent |
48
Chrome only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
79
Edge only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
No
|
No
|
35
Opera only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
No
|
48
Chrome only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
48
Chrome only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
46
|
35
Opera only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
3.2
|
5.0
Samsung Internet only supports the following
touchEventInit properties:
touches ,
targetTouches ,
changedTouches .
|
See also
-
TouchEvent
, the interface of the objects it constructs.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent