shift 键被按了吗?

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function isKeyPressed(event)
  5. {
  6. if (event.shiftKey==1)
  7. {
  8. alert("The shift key was pressed!")
  9. }
  10. else
  11. {
  12. alert("The shift key was NOT pressed!")
  13. }
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body onmousedown="isKeyPressed(event)">
  19.  
  20. <p>在文档中点击某个位置。消息框会告诉你是否按下了 shift 键。</p>
  21.  
  22. </body>
  23. </html>