Just wondering is there is a way to force play canvas to go full screen like this code does:
{
if(this.app.keyboard.isPressed(pc.KEY_P)) {
this.app.graphicsDevice.fullscreen = true;
}
console.log('test');
};
but without needing user input?
many thanks!
Unfortunately that is not possible without user input, in chrome I get âFailed to execute ârequestFullScreenâ on âElementâ: API can only be initiated by a user gesture.â , this mechanism is put in place so spams website cannot go full screen automatically.
Just to add on to what @Saad_Haider said, though it wonât be possible, if you want to avoid fullscreen only coming on if the user initiates an action in the game, you can bring up a quick DOM modal the moment your game loads, with a button that says âEnter Fullscreenâ or similar. That way, it will not take away from the aesthetics of the game. You can read on how to initiate a particular action on the DOMContentLoaded event here - Window: DOMContentLoaded event - Web APIs | MDN.