---
title: addEventListener
slug: viewer-3d/methods/addEventListener
docTags: 
createdAt: 2024-08-28T18:54:18.655Z
---

Adds an event listener to the viewer instance.

## Example

::codepen{url="https://codepen.io/Catenda/embed/xxoLMKR"}

## Usage

```javascript
const eventCallback = (event) => {
  console.log(event);
};
const listener = viewer3d.addEventListener("eventName", eventCallback);
```

## Parameters

### eventName

Name of the viewer event to listen for.

Valid event names can be found in each **Event** page.

| **Type** | **Required** |
| -------- | ------------ |
| String   | Yes          |

### eventCallback

Function invoked when the event is triggered. The function receives an event object as an argument which includes data specific to the event type.

| **Type**                  | **Required** |
| ------------------------- | ------------ |
| `(event: Object) => Void` | Yes          |

## Return Value

The event listener object.

| **Type** |
| -------- |
| Object   |

**Properties**

| **Name** | **Type**     | **Description**            |
| -------- | ------------ | -------------------------- |
| `remove` | `() => Void` | Removes the event listener |

