Wakelock
It is possible to keep the screen on in KaiOS.
Disable sleep
To keep the screen on, use the following code:
wakelock = navigator.requestWakeLock('screen');
where wakelock is a variable that you can access later to unlock wakelock.
You can also replace screen with another resource to keep alive, like cpu or gps. See the links at the bottom of the page for more info.
Enable sleep
After you are done with whatever you're doing, you can unlock wakelock.
wakelock.unlock();
where wakelock is that variable you set earlier.
Turn off wakelock on manual sleep
You can attach wakelock.unlock() to the blur event of the window or document.
window.addEventListener('blur',function(){ wakelock.unlock(); }
Videos
You do not need to set a wakelock for a video, videos automatically get screen wakelock when playing.
See also
page revision: 3, last edited: 05 Mar 2021 07:23
