Prevent the Screen From Dimming or Turning Off on Android, and Keep a Web Game Awake
Youâre reading a recipe, following a guide, or watching your score on a game-over screen, and the screen dims and goes dark. On a Galaxy phone or tablet there are four settings that decide this, and websites can also ask to keep the screen on. This guide covers the settings first, then the few lines of code a site like byteslip.org would use to keep the screen awake during a game.
Warnings
ImportantA screen that stays on uses more battery. Samsungâs user guide also warns that showing the same still image for a long time may leave ghost-like afterimages, so donât leave a static page on for hours. Samsung says screen timeout canât be turned off completely.
What You Need
- An Android phone or tablet. Written for a Galaxy Tab A9+ on One UI; Pixel paths are noted where they differ.
- For step 4: a charger, and Developer options (our Stay awake guide shows how to turn them on).
- For step 6: a site served over HTTPS. The Screen Wake Lock API only works in secure contexts.
How this was tested: Settings paths come from Samsung support pages, the Galaxy Tab A9+ user guide, Pixel Phone Help and Android Developers. On Nov 19, 2026 we ran the wake lock code from step 6 on a byteslip.org page in headless Chrome 156. The request returned a screen lock. When we released that lock the way the system does and fired visibilitychange, the code took a new one, and allowSleep() released it. Headless Chrome canât hide a tab the way a phone does, so the automatic release when you switch apps is as MDN documents it, not something we watched on a device.
Timeout â keep on while viewing â power saving â plugged in â videos â websites
Steps 1â5 are settings anyone can change. Step 6 is for people who build websites.
-
Step 1: Make the screen timeout longer
Open Settings, tap Display, then Screen timeout, and pick a time. Samsung says Galaxy devices offer 15 seconds to 10 minutes, with 30 seconds as the default, and the timeout canât be switched off. Pixel phones use Settings > Display (Display & touch on newer versions) > Screen timeout. Pixel also has Adaptive timeout, which can turn the screen off early when youâre not using it.
The timer only counts time without a touch. While you tap, the screen stays on.
-
Step 2: Samsung: turn on Keep screen on while viewing
Galaxy devices can use the front camera to see that youâre looking at the screen and keep it on. Samsung calls it Keep screen on while viewing (older versions: Smart stay). Where it lives depends on your One UI version:
- Current Samsung help: Settings > Display > Screen timeout > Keep screen on while viewing.
- Galaxy Tab A9+ user guide (Android 13 edition): Settings > Advanced features > Motions and gestures > Keep screen on while viewing.
Quickest: tap the search icon in Settings and type âkeep screen onâ. Samsung notes it may not work well in low light or if your face isnât clearly visible, and that it may not be available on some devices or software versions.
-
Step 3: Check power saving and adaptive brightness
- Power saving may cut screen timeout to 15 seconds, Samsung says. Find it under Settings > Battery and device care > Battery > Power saving (names vary by version).
- Adaptive brightness: if the screen gets darker and then brighter while youâre using it, thatâs brightness following the room light, not the timeout. Turn it off in Settings > Display.
- A case or dirt over the proximity sensor near the front camera can also make the screen dim or turn off, Samsung says.
-
Step 4: Plugged in: Stay awake in Developer options
For long, plugged-in jobs (a recipe on the counter, a tablet as a scoreboard), Androidâs Stay awake switch in Developer options keeps the screen on while the device is plugged in. Android Developers: it âsets your screen to stay on while the device is plugged in.â Unplug, and the normal timeout returns.
Full steps and when to use it: Keep Android Awake While Charging. When youâre done, turn Developer options off.
-
Step 5: Watching video: go full screen
Samsungâs screen timeout page says video apps usually keep the screen on, but a video playing inside a browser page without full screen may still let the timeout kick in. Tap the videoâs full-screen icon. More ways to go full screen: How to Make a Website Full Screen on Android.
-
Step 6: Developers: keep the screen on with the Screen Wake Lock API
Web pages can ask the browser to keep the screen on while theyâre visible. This is the code weâd use on a Byteslip game. It isnât on the live games yet:
let wakeLock = null; async function keepScreenOn() { if (!('wakeLock' in navigator)) return; // older browser: the timeout setting applies try { wakeLock = await navigator.wakeLock.request('screen'); wakeLock.addEventListener('release', () => { // The lock ended (you released it, or the tab was hidden). Update any on-screen indicator. }); } catch (err) { console.warn('Wake lock refused:', err.name); // for example power saving or low battery } } async function allowSleep() { if (wakeLock) { await wakeLock.release(); wakeLock = null; } } // Android releases the lock when you switch tabs or apps. Take it back when the page returns. document.addEventListener('visibilitychange', () => { if (wakeLock !== null && document.visibilityState === 'visible') keepScreenOn(); });Then call it when a run starts and release it a little after it ends. The names here are placeholders for your gameâs own functions:
startButton.addEventListener('click', () => { startGame(); keepScreenOn(); }); function onGameOver() { showScoreAndLeaderboard(); setTimeout(allowSleep, 2 * 60 * 1000); // let the screen sleep two minutes after a run ends }- Why a game needs it: in Mr. Snakey you tap the D-pad all the time, and every tap counts as activity. The screen goes dark in the quiet moments: a pause, or the game-over screen while you read your score and the global leaderboard.
- MDN says a request can be refused, for example by power saving or a low battery, and the lock is released when the page is hidden. Thatâs why the code catches errors and listens for
visibilitychange. - Release it when you no longer need it, and consider a visible on/off control so people know.
Match the method to the moment
FAQ
Can I turn screen timeout off completely?
Not on Galaxy devices, Samsung says; 10 minutes is the longest choice. For longer, use Stay awake while plugged in.
Does Keep screen on while viewing record me?
Samsung describes it as using the front camera to detect your face so the screen stays on. If youâd rather not use the camera, use a longer timeout instead.
Can a website keep my screen on without asking?
Browsers may allow it without a prompt, but only while the page is visible. Switching tabs or apps releases it, and MDN says browsers can refuse it, for example in power saving.
Why does my screen still turn off with a 10-minute timeout?
Check power saving, which can shorten the timeout, and whether a case covers the proximity sensor.
Related Byteslip guides
- Keep Android Awake While Charging â the Stay awake switch, step by step.
- How to Make a Website Full Screen on Android â full screen plus a wake lock for games.
- Add a Website to the Home Screen on Samsung Android â one-tap icons for pages you keep open.
- Turn Developer Options Off Completely on Android â tidy up after Stay awake.
Official docs
Timeout range, default and no-off rule: Samsung: Change the screen timeout and Samsung: Stop the screen brightness from dimming. Keep screen on while viewing, Smart stay and availability: Samsung: Stop the screen brightness from dimming, Samsung: Screen turns off while using Galaxy phone or tablet and Galaxy Tab A9+ user guide (Android 13 edition). Power saving and the proximity sensor: Samsung: Change the screen timeout and Samsung: Stop the screen brightness from dimming. Pixel path: Pixel Phone Help: screen and display settings. Stay awake: Android Developers: Configure on-device developer options. Wake lock requests, refusals, release and re-acquiring: MDN: Screen Wake Lock API and Chrome for Developers: Stay awake with the Screen Wake Lock API.
See more free browser games with leaderboards.
