键盘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;

 

posted on 2013-10-30 23:29  青春丶冭柔情  阅读(265)  评论(0编辑  收藏  举报

导航