Skip to content

1681-engine / mobile / keepScreenOn

Function: keepScreenOn() ​

ts
function keepScreenOn(wakeLock?, doc?): Promise<() => void>;

Defined in: src/mobile/screen.ts:39

Keeps the screen on while the game runs (a phone dims and locks during a cut scene or a long think otherwise), through the Screen Wake Lock API. The browser drops the lock whenever the page is hidden, so it is asked for again each time the page comes back. Resolves to the release; does nothing where the API is missing or refuses.

Parameters ​

ParameterTypeDefault value
wakeLockWakeLockLike | undefined...
doc| Pick<Document, "addEventListener" | "removeEventListener" | "visibilityState"> | undefinedglobalThis.document

Returns ​

Promise<() => void>

Released under the MIT License.