forked from mdn/dom-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
28 lines (23 loc) · 660 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
window.addEventListener("load", startup, false);
function startup() {
// Get the reference to video
const video = document.getElementById("video");
// On pressing ENTER call toggleFullScreen method
document.addEventListener("keypress", function(e) {
if (e.key === 'Enter') {
toggleFullScreen(video);
}
}, false);
}
function toggleFullScreen(video) {
if (!document.fullscreenElement) {
// If the document is not in full screen mode
// make the video full screen
video.requestFullscreen();
} else {
// Otherwise exit the full screen
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}