HTML代码
<input type="text" οnkeydοwn="keyNumAll(event);" >
Javascript 代码
function keyNumAll(evt){
//兼容IE和Firefox获得keyBoardEvent对象
evt = (evt) ? evt : ((window.event) ? window.event : "");
var key = evt.keyCode?evt.keyCode:evt.which;//兼容IE和Firefox获得keyBoardEvent对象的键值
console.info(key);//显示按键键值
}
}