All examples · Input

Full screen

What this example shows

The game itself asks for full screen: click or press F. enterFullscreen(), on the game handle, puts it on the whole monitor scaled by fullscreenScaling: 'integer' by default, whole multiples, every game pixel a square and bars round the edge in the background colour. Esc leaves, and so does exitFullscreen(). Leaving puts it back exactly as it was in the page.

Two rules come from the browser, not the engine. It is only granted in answer to the player, a click or a key: from a timer or at start-up it is refused, and from usePointer().onDown or a justPressed check, as here, it works. And some places have none: on an iPhone only a video may go full screen. There enterFullscreen() answers false instead of throwing, and the game says so and carries on.

isFullscreen() is read every frame rather than remembered, because Esc leaves without asking the game. Every example also has a full screen button in the playground bar, which calls the same thing.

Starting