📌  相关文章
📜  如何禁用网站的向上和向下箭头向下滚动 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:08.509000             🧑  作者: Mango

代码示例1
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);