Register keyboard interactions to mute/pause/set fullscreen mode

This commit is contained in:
Yohann D'ANELLO 2020-10-18 11:32:57 +02:00
parent 9fc94cf0de
commit 1a0fcb9c44
1 changed files with 23 additions and 0 deletions

View File

@ -73,3 +73,26 @@ startPeerConnection = () => {
}
}
}
// Register keyboard interactions
window.onkeydown = function (event) {
let viewer = document.getElementById("viewer")
// Toggle fullscreen mode
if (event.key === "f") {
if (document.fullscreen)
document.exitFullscreen().then()
else
viewer.requestFullscreen().then()
}
// (Un)mute the stream
else if (event.key === "m") {
viewer.muted = !viewer.muted;
}
// Pause the stream
else if (event.key === " ") {
if (viewer.paused)
viewer.play()
else
viewer.pause()
}
}