HTML5 Game Not Stealing Focus

“The game does not “steal focus” in the browser, which means that the arrow keys and space button can not be used. You need to fix this and re-upload.” - I just got this from a website I tried to upload my game to. How to solve this issue?

I’ll look at it and notify you when I got a solution :slight_smile:

Try this:

Go the Game Develop folder, then in JSPlatform, Runtime and open runtimegame.js ( with Notepad or a good text editor like Notepad++ )
Search for the line where there is renderer.view.onmousedown = function(e){ and paste window.focus(); below, just like this:

renderer.view.onmousedown = function(e){ window.focus(); game.onMouseButtonPressed(e.button === 2 ? 1 : 0); [...]

Then, locate the line beginning with window.addEventListener(‘click’, function(e) { ( a bit after ) and paste again window.focus(); the line after:

window.addEventListener('click', function(e) { window.focus(); e.preventDefault(); return false; }, false);

Save the file.
Then, export again your project and let me know if the website does or doesn’t complain anymore about stealing focus :slight_smile: