Best Way to maintain keyboard focus on game
Shri

Gio,

 

My last game PT Raid uses either keyboard, mouse or touch to control the boat.

Sometimes, on a webpage, on keyboard input, the game will loose the focus and you have to click the game with the mouse to regain it.

I was wondering what is the best way to ensure that the focus remains on the game ?

I searched around, and the way to go seems to be to prevent the default behavior via  event.preventDefault() but I was not sure

where  that code should go, in the html file or in the app ?

 

As usual, any help you can provide will be appreciated.

 

cheers,

Shri

All 2 Comments
Gio

Hey Shri

 

I tried your game but couldn't get that to happen. The only way I could make it happen is if I just click on a different window, in which case, sadly there's nothing you can do. As far as I know there is absolutely no way to intercept input events outside the browser window, presumably for security reasons.

 

If the event happens inside the browser window (but say, on a different div), your WADE App should get it (unless the other div stops it).

Shri

Gio,

 

Thanks for checking. The html is almost identical to the index.html you release with the engine, so I don't think there is another div catching the events.

 

cheers,

Shri

Post a reply
Add Attachment
Submit Reply
Login to Reply