代码
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>Web键盘重写</title>
5 <script type="text/javascript">
6 function OnKeyDown(e) {
7 e = e || window.event;
8 var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
9 switch (keyCode) {
10 case 27:
11 alert("Esc");
12 break;
13 case 112:
14 alert("F1");
15 break;
16 case 113:
17 alert("F2");
18 break;
19 case 114:
20 alert("F3");
21 break;
22 case 115:
23 alert("F4");
24 break;
25 case 116:
26 alert("F5");
27 break;
28 default:
29 break;
30 }
31 e.keyCode = 0;
32 e.returnValue = false;
33 }
34 function OnMouseDown(e) {
35 e = e || window.event;
36 var isRightBtn = e.button == 0 || e.button == 0;
37
38 if (isRightBtn) {
39 if (!document.getElementById("rgtMouse")) {
40 var a = document.createElement("div");
41 with (a.style) {
42 textAlign = 'left';
43 background = '#f3f3f3';
44 border = '1px solid #ccc';
45 fontSize = '12px';
46 position = 'absolute';
47 padding = "5px";
48 width = 'auto';
49 height = 'auto';
50 zIndex = '999';
51 overflow = 'hidden';
52 display = "none";
53 }
54 a.id = "rgtMouse";
55 document.body.appendChild(a);
56 }
57 document.getElementById("rgtMouse").innerHTML = "Hi";
58 document.getElementById("rgtMouse").style.display = "block";
59 }
60 e.returnValue = false;
61 }
62 document.oncontextmenu = OnMouseDown;
63 document.onkeydown = OnKeyDown;
64 </script>
65 </head>
66 <body >
67 <br />
68 <p>Hello World! </p>
69 </body>
70 </html>
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>Web键盘重写</title>
5 <script type="text/javascript">
6 function OnKeyDown(e) {
7 e = e || window.event;
8 var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
9 switch (keyCode) {
10 case 27:
11 alert("Esc");
12 break;
13 case 112:
14 alert("F1");
15 break;
16 case 113:
17 alert("F2");
18 break;
19 case 114:
20 alert("F3");
21 break;
22 case 115:
23 alert("F4");
24 break;
25 case 116:
26 alert("F5");
27 break;
28 default:
29 break;
30 }
31 e.keyCode = 0;
32 e.returnValue = false;
33 }
34 function OnMouseDown(e) {
35 e = e || window.event;
36 var isRightBtn = e.button == 0 || e.button == 0;
37
38 if (isRightBtn) {
39 if (!document.getElementById("rgtMouse")) {
40 var a = document.createElement("div");
41 with (a.style) {
42 textAlign = 'left';
43 background = '#f3f3f3';
44 border = '1px solid #ccc';
45 fontSize = '12px';
46 position = 'absolute';
47 padding = "5px";
48 width = 'auto';
49 height = 'auto';
50 zIndex = '999';
51 overflow = 'hidden';
52 display = "none";
53 }
54 a.id = "rgtMouse";
55 document.body.appendChild(a);
56 }
57 document.getElementById("rgtMouse").innerHTML = "Hi";
58 document.getElementById("rgtMouse").style.display = "block";
59 }
60 e.returnValue = false;
61 }
62 document.oncontextmenu = OnMouseDown;
63 document.onkeydown = OnKeyDown;
64 </script>
65 </head>
66 <body >
67 <br />
68 <p>Hello World! </p>
69 </body>
70 </html>