metaKeyEvent Property

事件对象参考手册Event Object

Definition and Usage

The metaKey event property returns a Boolean value that indicates whether the "meta" key was pressed and held down when the event occurred.

Syntax

event.metaKey


Example

Example

The following example can indicate whether the "meta" key was held down when the mouse button was clicked:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function isKeyPressed(event){
    if (event.metaKey==1){
alert("Meta key pressed!");
    }else{
alert("Meta key not pressed!");
    }
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">

<p>Click somewhere in the document. An alert box will tell you whether you pressed the meta key.</p>

</body>
</html>

Try it Yourself »


事件对象参考手册Event Object Other Extensions