2 ms·
I notice that some games on itch.io are able to capture the down arrow key and stop it from scrolling the page (ex.: https://elastiskalinjen.itch.io/oh-high htt
by phendrenad2 3y ago
I notice that some games on itch.io are able to capture the down arrow key and stop it from scrolling the page (ex.: https://elastiskalinjen.itch.io/oh-high https://elastiskalinjen.itch.io/oh-high).
- JSLegendDev 3y agoThe issue should now be fixed thanks to the following code : // prevent itch.io scrolling window.addEventListener("keydown", function (e) { if ([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) { e.preventDefault(); } });
- deepfriedrice 3y agoObligatory pedantry https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- gibolt 3y agokeyCode is deprecated. 'key' would be optimal and more readable :D https://stackoverflow.com/a/44213036/974045 https://stackoverflow.com/a/44213036/974045