# 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](https://docs.digitalsamba.com/reference/sdk/methods/removeframeeventlistener) method.
{% endhint %}
