Was the "META" key pressed when the mouse button was clicked:
if (event.metaKey) {
let text = "The META key was pressed!"
} else {
let text = "The META key was NOT pressed!");
}
Try it Yourself »
The metaKey
property returns true
if the META key is pressed when a mouse event is triggered, otherwise it returns false
.
The metaKey
property is read-only.
Not all keyboards have a META key.
On Windows it is the Window ⊞ key. On Mac machines it is the Cmd ⌘ key.
event.metaKey
Return Value: | A Boolean.true if the META key was pressed when a mouse event occured, otherwise false . |
---|---|
DOM Version: | DOM Level 2 Events |
event.metaKey
is a DOM Level 2 (2001) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!