<head> <script type="text/javascript"> function whichButton() { alert(event.keyCode) }
</script> </head>
<body onkeyup="whichButton()"> <p><b>Note:</b> Make sure the right frame has focus when trying this example!</p> <p>Press a key on your keyboard. An alert box will alert the unicode of the key pressed.</p> </body>
</html>
单击任何地方显示鼠标在页面的坐标
<html> <head>
<script type="text/javascript"> function coordinates() { x=event.screenX y=event.screenY alert("X=" + x + " Y=" + y) }
<p> Click somewhere in the document. An alert box will alert the x and y coordinates of the cursor. </p>
</body> </html>
显示SHIFT是否被按下
<html> <head>
<script type="text/javascript"> function isKeyPressed() { if (event.shiftKey==1) { alert("The shift key was pressed!") } else { alert("The shift key was NOT pressed!") } }