KeyboardEvent:ctrlKey 属性
**KeyboardEvent.ctrlKey
** 只读属性返回一个布尔值,指示在事件发生时是否按下了 control 键 (true
) 或未按下 (false
)。
值
布尔值。
示例
html
<html lang="en">
<head>
<title>ctrlKey example</title>
<script>
function showChar(e) {
alert(`Key Pressed: ${e.key}\nCTRL key pressed: ${e.ctrlKey}\n`);
}
</script>
</head>
<body onkeypress="showChar(event);">
<p>
Press any character key, with or without holding down the CTRL key.<br />
You can also use the SHIFT key together with the CTRL key.
</p>
</body>
</html>
规范
规范 |
---|
UI 事件 # dom-keyboardevent-ctrlkey |
浏览器兼容性
BCD 表格仅在浏览器中加载