Tips:点此可运行HTML源码

获取鼠标键盘ID

canRun

获取鼠标键盘ID

 1 <html>
 2 <head>
 3     <title>获取鼠标键盘ID</title>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <meta http-equiv="Content-Language" content="zh-CN" />
 6     <script type="text/javascript" src=""></script>
 7     <link rel="stylesheet" href="" type="text/css"></link>
 8 </head>
 9 <body>
10 <script type="text/javascript">
11 var count = 0;
12 document.onmousedown=document.onkeypress=function(e) {
13     var code;
14     if  (!e) {
15       var e=window.event;
16     }
17     
18     if(e.keyCode) {
19       code=e.keyCode;
20     }else if(e.which){
21       code   =   e.which;
22     }
23     if(count++%21 ==20) code +="<br/>";
24     document.getElementById("code").innerHTML = document.getElementById("code").innerHTML+"("+String.fromCharCode(code)+":"+code+")";
25 }
26 </script>
27 <div id="code"></div>
28 </body>
29 </html>

PS:纯HTML,可运行,点击左上方Tips链接可至源码运行页。

 

posted @ 2012-07-11 20:11  Zjmainstay  阅读(788)  评论(0编辑  收藏  举报