<html>
<body onmousedown="isKeyPressed(event)">
<p>单击文档中的某处。 一个警告框会告诉您在 onmousedown 事件发生时是否按下了 CTRL 键。</p>
<p><strong>提示</strong>:在单击文档之前尝试按住 CTRL 键(在您的键盘上)。</p>
<script>
function isKeyPressed(event) {
if (event.ctrlKey) {
alert("按下了 CTRL 键!");
} else {
alert("未按下 CTRL 键!");
}
}
</script>
</body>
</html>