// The wake lock sentinel. let wakeLock = null; // Function that attempts to request a screen wake lock. const requestWakeLock = async () => { try { wakeLock = await navigator.wakeLock.request(); wakeLock.addEventListener('release', () => { console.log('Screen Wake Lock released:', wakeLock.released); }); console.log('Screen Wake Lock released:', wakeLock.released); } catch (err) { console.error(`${err.name}, ${err.message}`); } }; // Request a screen wake lock… await requestWakeLock(); // …and release it again after 5s. window.setTimeout(() => { wakeLock.release(); wakeLock = null; }, 5000);
Screen Wake Lock Demo
https://wake-lock-demo.glitch.me/
Stay awake with the Screen Wake Lock API
To avoid draining the battery, most devices will quickly fall asleep when left idle. While this is fine most of the time, there are some applications that need to keep the screen awake in order to complete some work.
https://web.dev/wake-lock/


Seonglae Cho