MouseEvent: shiftKey-Eigenschaft
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.
Die schreibgeschützte Eigenschaft MouseEvent.shiftKey
ist ein boolescher Wert, der angibt, ob die Shift-Taste gedrückt wurde oder nicht, wenn ein bestimmtes Mausereignis auftritt.
Wert
Ein boolescher Wert, bei dem true
anzeigt, dass die Taste gedrückt ist, und false
anzeigt, dass die Taste nicht gedrückt ist.
Beispiele
Dieses Beispiel protokolliert die shiftKey
-Eigenschaft, wenn Sie ein click
-Ereignis auslösen.
HTML
<p>Click anywhere to test the <code>shiftKey</code> property.</p>
<p id="log"></p>
JavaScript
let log = document.querySelector("#log");
document.addEventListener("click", logKey);
function logKey(e) {
log.textContent = `The shift key is pressed: ${e.shiftKey}`;
}
Ergebnis
Spezifikationen
Specification |
---|
UI Events # dom-mouseevent-shiftkey |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
shiftKey |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support