MouseEvent: metaKey property
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 MouseEvent.metaKey chỉ đọc là một giá trị boolean cho biết liệu phím meta có được nhấn hay không khi một sự kiện chuột nhất định xảy ra.
Xin lưu ý rằng nhiều hệ điều hành liên kết chức năng đặc biệt với phím meta, vì vậy thuộc tính này có thể là false ngay cả khi phím này thực sự được nhấn.
Ví dụ trên Windows, phím này có thể mở menu Start.
Note: Trên bàn phím Macintosh, phím này là phím command (⌘). Trên bàn phím Windows, phím này là phím Windows (⊞).
Giá trị
Một giá trị boolean, trong đó true chỉ ra rằng phím được nhấn và false chỉ ra rằng phím đó được not nhấn.
Ví dụ
Ví dụ này ghi lại thuộc tính metaKey khi bạn kích hoạt sự kiện click.
HTML
<p>Click anywhere to test the <code>metaKey</code> property.</p>
<p id="log"></p>
JavaScript
let log = document.querySelector("#log");
document.addEventListener("click", logKey);
function logKey(e) {
log.textContent = `The meta key is pressed: ${e.metaKey}`;
}
Kết quả
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Pointer Events> # dom-mouseevent-metakey> |