//注册火狐监听键盘事件
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);
}
}