键盘enter事件 兼容FF和IE和Opera

function keyDownSearch(e) {
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            
            if (code == 13) {
                doSomething();//具体处理函数
            
                return false;
            }
            return true;
        }
        
    document.onkeypress = keyDownSearch;
原文地址:https://www.cnblogs.com/wh-king/p/3398249.html