Posted December 06, 2019 by turtlepanda.games
#itch.io #embed
You’d think after all the other games I’ve been testing where I have problems with keyboard entry in the browser that I wouldn’t make the same mistake. Pressing the spacebar in the emulator was causing the page to scroll on my gamepage, so I added a quick fix. I’ll share it here if any other devs encounter the same thing when embedding their game:
I added this in a script block in the page to disable the scrollbar if the emulator is not selected:
window.onkeydown = function(e) {
if (e.keyCode == 32 && e.target == document.body) {
e.preventDefault();
}
};
Drop in the keycodes you need for your game, or the ones you’re having problems with. It should really only be a problem with the arrow keys and the spacebar, though (I think).