KeyboardEvent: thuộc tính altKey
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính chỉ đọc KeyboardEvent.altKey là một
giá trị boolean cho biết phím alt (Option hoặc ⌥ trên macOS) có được nhấn (true) hay không (false) khi
sự kiện xảy ra.
Giá trị
Một giá trị boolean.
Ví dụ
html
<p>
Nhấn bất kỳ phím ký tự nào, có hoặc không giữ phím ALT.<br />
Bạn cũng có thể sử dụng phím SHIFT cùng với phím ALT.
</p>
<pre id="output"></pre>
js
const output = document.getElementById("output");
function showChar(e) {
output.textContent = `Phím KeyDown: "${e.key}"
Phím ALT KeyDown: ${e.altKey}
`;
}
document.addEventListener("keydown", showChar);
Đặc điểm kỹ thuật
| Specification |
|---|
| UI Events> # dom-keyboardevent-altkey> |