W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body onmousedown="isKeyPressed(event)"> <p>单击文档中的某处。当 onmousedown 事件发生时,警告框会提示您 CTRL 键是否被按下。</p> <p><b>提示:</b>请在单击文档之前尝试按住 CTRL 键(在您的键盘上)。</p> <script> function isKeyPressed(event) { if (event.ctrlKey) { alert("The CTRL key was pressed!"); } else { alert("The CTRL key was NOT pressed!"); } } </script> </body> </html>