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