Skip to main content

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

Feature Request: Open HTML5 game in new Tab.

A topic by jfkEO1010etc created Feb 14, 2021 Views: 301 Replies: 2
Viewing posts 1 to 3

As I had conflicts between event handlers of itch.io and my games, I think it would be good to have that option, open the game in a new tab that has no game-specific handlers by it's own, increasing overall compatibility. Frankly, I don't know how you guys get your cursorkeys to work at all.

After I removed itch.io's keydown and keyup handlers via browser dev tools, mine suddently worked - but only until I clicked the page outside of the iframe. Then it didn't work anymore, despite refocusing the iframe. Having such conflicts on a game publishing platform seems kind of odd to me. Easy fix would be a new tab option.

(2 edits)

(Rant removed)... took me a while, here is how you must set up the event handler:

function keysinit()
{
mycanvas=document.getElementById('3darea');
mycanvas.addEventListener('keypress', keymerk);
mycanvas.addEventListener('keydown', keymerk);
mycanvas.addEventListener('keyup', keyrelease);
mycanvas.setAttribute('tabindex','0');
mycanvas.focus();
}

it won't work without that tab index thingie BTW the above was for coppercube, run onload. 3darea is the ID of the canvas. For itch.io you must put the keys event handler on the canvas, not on the window, body or document.

Additionally you also need something like this in the html part:

<canvas id="3darea" onclick="document.getElementById('3darea').focus();" width="800" height="600" style="background-color:#"#000000"">
</canvas>

Otherwise the canvas will lose focus, despite being clicked.