Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Solved: Problem of keys not working, loss of focus etc. on itch.io for web games.

A topic by jfkEO1010etc created Jan 22, 2022 Views: 466
Viewing posts 1 to 1
(+2)

If you had like me troubles getting your js keys input to work on itch.io, this solved the issue for me: Assume you have some sort of canvas, and a script section in the html file, add an onclick handler to the canvas and a function to the script section, like this:

<body>

<div align="center">

<canvas id="3darea" width="800" height="600" style='background-color:#"#000000"' onclick='refocus_myself()'>

</canvas>

</div>

<script type="text/javascript">

<!--

//....

function refocus_myself(){

var mycanvas= mycanvas=document.getElementById('3darea'); 

mycanvas.setAttribute('tabindex','0'); 

mycanvas.focus();

}

-->

</script>

<br/>

</body>

it's that one tabindex thingie that does the trick.

This topic has been auto-archived and can no longer be posted in because there haven't been any posts in a while.