Wakelock
signalbar-1 This article is short…
You can help by expanding it!

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

Navigator.requestWakelock() on MDN

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License