日期:2014-05-17 浏览次数:20456 次
<html> <head> <script language="javascript"> ns4 = (document.layers) ? true : false; ie4 = (document.all) ? true : false; function keyDown(e){ if(ns4){ var nkey=e.which; var iekey='现在是ns浏览器'; var realkey=String.fromCharCode(e.which); } if(ie4){ 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\''} } document.write('ns浏览器中键值:'+nkey+'\n'+'ie浏览器中键值:'+iekey+'\n'+'实际键为'+realkey); } document.onkeydown = keyDown; if(ns4){ document.captureEvents(Event.KEYDOWN); } </script> </head> <body> //Javascript Document. <hr> <center> <h3>请按任意一个键。。。。</h3> </center> </body> </html>