MouseEvent: shiftKey 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 chỉ đọc MouseEvent.shiftKey là giá trị boolean cho biết liệu phím shift có được nhấn hay không khi xảy ra sự kiện chuột nhất định.
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 shiftKey khi bạn kích hoạt sự kiện click.
HTML
html
<p>Click anywhere to test the <code>shiftKey</code> property.</p>
<p id="log"></p>
JavaScript
js
let log = document.querySelector("#log");
document.addEventListener("click", logKey);
function logKey(e) {
log.textContent = `The shift key is pressed: ${e.shiftKey}`;
}
Kết quả
Thông số kỹ thuật
| Specification |
|---|
| Pointer Events> # dom-mouseevent-shiftkey> |