KeyboardEvent: ctrlKey 屬性
KeyboardEvent.ctrlKey 只讀屬性返回一個布林值,指示在事件發生時 control 鍵是否被按下(true)或未被按下(false)。
值
一個布林值。
示例
html
<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>
<pre id="output"></pre>
js
const output = document.getElementById("output");
function showChar(e) {
output.textContent = `Key KeyDown: "${e.key}"
CTRL key KeyDown: ${e.ctrlKey}
`;
}
document.addEventListener("keydown", showChar);
規範
| 規範 |
|---|
| UI 事件 # dom-keyboardevent-ctrlkey |
瀏覽器相容性
載入中…