W3School TIY
编辑您的代码:
<html> <head> <script type="text/javascript"> function isKeyPressed(event) { if (event.ctrlKey==1) { alert("The CTRL key was pressed!") } else { alert("The CTRL key was NOT pressed!") } } </script> </head> <body onmousedown="isKeyPressed(event)"> <p>Click somewhere in the document. An alert box will tell you if you pressed the CTRL key or not.</p> </body> </html>
查看结果: