# TouchEvent

Class · category: Input Devices

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/platform/input/touch-event.js#L103

The TouchEvent object is passed into all event handlers registered on the [TouchDevice](https://api.playcanvas.com/engine/classes/TouchDevice.md).
The events are:

- [TouchDevice.EVENT_TOUCHSTART](https://api.playcanvas.com/engine/classes/TouchDevice.md#event_touchstart)
- [TouchDevice.EVENT_TOUCHEND](https://api.playcanvas.com/engine/classes/TouchDevice.md#event_touchend)
- [TouchDevice.EVENT_TOUCHMOVE](https://api.playcanvas.com/engine/classes/TouchDevice.md#event_touchmove)
- [TouchDevice.EVENT_TOUCHCANCEL](https://api.playcanvas.com/engine/classes/TouchDevice.md#event_touchcancel)

## Constructors

### constructor

```ts
new TouchEvent(device: TouchDevice, event: TouchEvent)
```

Create a new TouchEvent instance. It is created from an existing browser event.

**Parameters**

- `device` ([`TouchDevice`](https://api.playcanvas.com/engine/classes/TouchDevice.md)): The source device of the touch events.
- `event` (`TouchEvent`): The original browser TouchEvent.

## Properties

### changedTouches

```ts
changedTouches: Touch[] = []
```

A list of touches that have changed since the last event.

### element

```ts
element: Element
```

The target DOM element that the event was fired from.

### event

```ts
event: TouchEvent
```

The original browser TouchEvent.

### touches

```ts
touches: Touch[] = []
```

A list of all touches currently in contact with the device.

## Methods

### getTouchById

```ts
getTouchById(id: number, list: Touch[]): Touch | null
```

Get an event from one of the touch lists by the id. It is useful to access touches by their
id so that you can be sure you are referencing the same touch.

**Parameters**

- `id` (`number`): The identifier of the touch.
- `list` ([`Touch`](https://api.playcanvas.com/engine/classes/Touch.md)`[]`): An array of touches to search.

**Returns** [`Touch`](https://api.playcanvas.com/engine/classes/Touch.md) `| null`: The [Touch](https://api.playcanvas.com/engine/classes/Touch.md) object or null.
