Table of Contents

Class TouchEvent

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The TouchEvent interface represents an UIEvent which is sent when the state of contacts with a touch-sensitive surface changes. This surface can be a touch screen or trackpad, for example. The event can describe one or more points of contact with the screen and includes support for detecting movement, addition and removal of contact points, and so forth.

[Value("TouchEvent")]
public class TouchEvent : UIEvent
Inheritance
TouchEvent
Inherited Members

Remarks

Touches are represented by the Touch object; each touch is described by a position, size and shape, amount of pressure, and target element. Lists of touches are represented by TouchList objects.

-Touch events
-GestureEvent

See also on MDN

Constructors

TouchEvent()

public TouchEvent()

TouchEvent(string, TouchEventInit)

The TouchEvent() constructor creates a new TouchEvent object.

public TouchEvent(string type, TouchEventInit eventInitDict = null)

Parameters

type string
eventInitDict TouchEventInit

Remarks

NOTE

If you construct a synthetic event using this constructor, that event will not be trusted, for security reasons.
Only browser-generated TouchEvent objects are trusted and only trusted events trigger default actions.

-TouchEvent, the interface of the objects it constructs.

See also on MDN

Properties

AltKey

The read-only altKey property of the TouchEvent interface returns a boolean value indicating whether or not the <kbd>alt</kbd> (Alternate) key is enabled when the touch event is created. If the <kbd>alt</kbd> key is enabled, the attribute's value is true. Otherwise, it is false.

[Value("altKey")]
public bool AltKey { get; }

Property Value

bool

A boolean value that is true if the <kbd>alt</kbd> key is enabled for this event; and false if the <kbd>alt</kbd> is not enabled.

Remarks

This property is {{ReadOnlyInline}}.

See also on MDN

ChangedTouches

The changedTouches read-only property is a TouchList whose touch points (Touch objects) varies depending on the event type, as follows:

[Value("changedTouches")]
public TouchList ChangedTouches { get; }

Property Value

TouchList

A TouchList whose Touch objects include all the touch points that contributed to this touch event.

Remarks

CtrlKey

The read-only ctrlKey property of the TouchEvent interface returns a boolean value indicating whether the <kbd>control</kbd> (Control) key is enabled when the touch event is created. If this key is enabled, the attribute's value is true. Otherwise, it is false.

[Value("ctrlKey")]
public bool CtrlKey { get; }

Property Value

bool

A boolean value that is true if the <kbd>control</kbd> key is enabled for this event; and false if the <kbd>control</kbd> is not enabled.

Remarks

This property is {{ReadOnlyInline}}.

See also on MDN

MetaKey

The read-only metaKey property of the TouchEvent interface returns a boolean value indicating whether or not the <kbd>Meta</kbd> key is enabled when the touch event is created. If this key is enabled, the attribute's value is true. Otherwise, it is false.

[Value("metaKey")]
public bool MetaKey { get; }

Property Value

bool

A boolean value that is true if the <kbd>Meta</kbd> key is enabled for this event; and false if the <kbd>Meta</kbd> is not enabled.

Remarks

This property is {{ReadOnlyInline}}.

NOTE

On Macintosh keyboards, this is the <kbd>⌘ Command</kbd> key. On Windows keyboards, this is the Windows key (<kbd>⊞</kbd>).

See also on MDN

ShiftKey

The read-only shiftKey property of the TouchEvent interface returns a boolean value indicating whether or not the <kbd>shift</kbd> key is enabled when the touch event is created. If this key is enabled, the attribute's value is true. Otherwise, it is false.

[Value("shiftKey")]
public bool ShiftKey { get; }

Property Value

bool

The boolean value true if the <kbd>shift</kbd> key is enabled for this event; and false if the <kbd>shift</kbd> key is not enabled.

Remarks

TargetTouches

The targetTouches read-only property is a TouchList listing all the Touch objects for touch points that are still in contact with the touch surface and whose Elementtouchstart event occurred inside the same target Element as the current target element.

[Value("targetTouches")]
public TouchList TargetTouches { get; }

Property Value

TouchList

A TouchList listing all the Touch objects for touch points that are still in contact with the touch surface and whose touchstart event occurred inside the same target Element as the current target element.

Remarks

Touches

touches is a read-only TouchList listing
all the Touch objects for touch points that are currently in contact
with the touch surface, regardless of whether or not they've changed or what their
target element was at Elementtouchstart time.

[Value("touches")]
public TouchList Touches { get; }

Property Value

TouchList

A TouchList listing all the Touch objects for touch points that are still in contact with the touch surface, regardless of whether or not they've changed or what their target element was at touchstart
time.

Remarks

You can think of it as how many separate fingers are able to be identified as touching
the screen.

NOTE

Touches inside the array are not necessarily ordered by order of occurrences (the
i-th element in the array being the i-th touch that happened). You cannot assume a specific order. To determine the order of occurrences of the touches, use the touch object IDs.

See also on MDN