document.onkeydown = keyDown;//IE處理按鍵事件 //Firefox,若document的屬性layers不存在,則window.evnet if(document.layers){ document.captureEvents(Event.KEYDOWN); } //keyDown()函數原型,IE:冒泡事件,event對象一個keyCode;Firefox:charCode屬性 function keyDown(e){ var ev = (e)?e:(window.event)?window.event:null; if(ev){ return (ev.charCode)?ev.charCode: ((ev.keyCode)?ev.keyCode:((ev.which)?ev.whick:null)); } return -1; }