Answers for "how to disable up and down arrow downscroll for a website"

1

how to disable up and down arrow downscroll for a website

var keys = {};
window.addEventListener("keydown",
    function(e){
        keys[e.keyCode] = true;
        switch(e.keyCode){
            case 37: case 39: case 38:  case 40: // Arrow keys
            case 32: e.preventDefault(); break; // Space
            default: break; // do not block other keys
        }
    },
false);
window.addEventListener('keyup',
    function(e){
        keys[e.keyCode] = false;
    },
false);
Posted by: Guest on June-20-2020

Code answers related to "how to disable up and down arrow downscroll for a website"

Browse Popular Code Answers by Language