回车键搜索代码 兼容性

回车键搜索代码 兼容性


document.onkeydown = keyDownSearch;
function keyDownSearch(e) {
        // 兼容FF和IE和Opera
        var theEvent = e || window.event;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code == 13) {
          // 想执行的操作
            return false;
        }
        return true;
    }
原文地址:https://www.cnblogs.com/king-ying/p/6518590.html