<html> <meta http-equiv="Content-Type" content="text/Html; charset=gb2312"> <head> <script language="Javascript"> var ie =navigator.appName=="Microsoft Internet Explorer"?true:false; function keyDown(e) { if(!ie) { var nkey=e.which; var iekey='現在是ns浏覽器'; var realkey=String.fromCharCode(e.which); } if(ie) { var iekey=event.keyCode; var nkey='現在是ie浏覽器'; var realkey=String.fromCharCode(event.keyCode); if(event.keyCode==32){realkey='\' 空格\''} if(event.keyCode==13){realkey='\' 回車\''} if(event.keyCode==27){realkey='\' Esc\''} if(event.keyCode==16){realkey='\' Shift\''} if(event.keyCode==17){realkey='\' Ctrl\''} if(event.keyCode==18){realkey='\' Alt\''} } alert('ns浏覽器中鍵值:'+nkey+'\n'+'IE浏覽器中鍵值:'+IEkey+'\n'+'實際鍵為'+realkey); } document.onkeydown = keyDown; </script> </head> <body> //Javascript Document. <hr> <center> <h3>請按任意一個鍵。。。。</h3> </center> </body> </Html>