Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The zoomlevelchange event of the CaptureController interface is fired when the captured display surface's zoom level changes.
Specifically, this occurs when:
increaseZoomLevel(), decreaseZoomLevel(), or resetZoomLevel() methods are called on a controller that is actively controlling a captured display surface.Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("zoomlevelchange", (event) => { })
onzoomlevelchange = (event) => { }
A generic Event.
zoomlevelchange usageWhen a captured display surface's zoom level changes, a zoomlevelchange event fires on the controller, which can be used to run an event handler such as the following. This writes the updated zoom level to an output element of some kind.
// Create controller and start capture
const controller = new CaptureController();
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia({
controller,
});
// ...
controller.addEventListener(
"zoomlevelchange",
() => (outputElem.textContent = `${controller.zoomLevel}%`),
);
See Using the Captured Surface Control API for a full working example.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
zoomlevelchange_event |
136 | 136 | No | 121 | No | No | No | No | No | No | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CaptureController/zoomlevelchange_event