MouseEvent.shiftKey

这篇翻译不完整。请帮忙从英语翻译这篇文章

MouseEvent.shiftKey 是只读属性,指出触发鼠标事件时是否按住了 shift

Syntax

var shiftKeyPressed = instanceOfMouseEvent.shiftKey

Return value

A boolean

Example

<html>
<head>
<title>shiftKey example</title>

<script type="text/javascript">

function showChar(e){
  alert(
    "Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
    + "charCode: " + e.charCode + "\n"
    + "SHIFT key pressed: " + e.shiftKey + "\n"
    + "ALT key pressed: " + e.altKey + "\n"
  );
}

</script>
</head>

<body onkeypress="showChar(event);">
<p>Press any character key, with or without holding down
 the SHIFT key.<br />
You can also use the SHIFT key together with the ALT key.</p>
</body>
</html>

Specifications

Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
MouseEvent.shiftKey
Working Draft No change from Document Object Model (DOM) Level 2 Events Specification.
Document Object Model (DOM) Level 2 Events Specification
MouseEvent.shiftKey
Recommendation Initial definition.

Browser compatibility

Feature Edge Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Edge Firefox Mobile (Gecko) Android IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) ? ? ? ? ?

See also

文档标签和贡献者

 此页面的贡献者: Dcfm
 最后编辑者: Dcfm,