FF和IE兼容的捕获回车事件问题

//注册火狐监听键盘事件
            document.onkeydown = keyDown;

            //键盘事件处理
            function keyDown(e) {
                //判断浏览器
                if(document.all) {
                    //IE
                    alert(event.keyCode);
                } else {
                    var keycode = e.which;
                    var realkey = String.fromCharCode(e.which);
                    alert("按键码: " + keycode + " 字符: " + realkey);
                }
            }
posted @ 2011-06-23 11:16  Grok.Yao  阅读(355)  评论(0编辑  收藏  举报