Was the "ALT" key pressed when the mouse button was clicked:
if (event.altKey) {
text = "The ALT key was pressed!";
} else {
text = "The ALT key was NOT pressed!";
}
Try it Yourself »
The altKey
property returns true
if the ALT key is pressed when a mouse event occurs.
Otherwise it returns false
.
The altKey
property is read-only.
On some keyboards, the ALT key is displayed as Option or Opt.
event.altKey
Return Value: | A Boolean. Returns true if the ALT key is pressed when a mouse event occurs.Otherwise it returns false . |
---|---|
DOM Version: | DOM Level 2 Mouse Events. |
event.altkey
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 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!