addFrameEventListener()

addFrameEventListener(eventName, target, listener)

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.

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.

addFrameEventListener is often used in conjunction with the removeFrameEventListener method.

Last updated