I\'m using the code:
window.onkeydown = function(e) { return !(e.keyCode == 32); };
which does exactly what I want, stops the page fro
Try checking if target is the body:
window.addEventListener('keydown', function(e) { if(e.keyCode == 32 && e.target == document.body) { e.preventDefault(); } });
body { height: 100000px; }
Demo