# addFrameEventListener()

Adds a JavaScript event listener to the iframe of the room. This is useful for listening to raw JS events - e.g. keyup or click. You can attach the listener either to the window or to the document.

```javascript
const keyUpEventListener = (payload) => {
   console.log('keyup', payload)
};
sambaFrame.addFrameEventListener('keyup', 'window', keyUpEventListener);

const clickEventListener = (payload) => {
   console.log('click', payload)
};
sambaFrame.addFrameEventListener('click', 'document', clickEventListener);
```

**Sample use case**: \
You may want to end the call if user presses double-space or some other custom key combination.

{% hint style="info" %}
**addFrameEventListener** is often used in conjunction with the [removeFrameEventListener](/reference/sdk/methods/removeframeeventlistener.md) method.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalsamba.com/reference/sdk/methods/addframeeventlistener.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
