MouseEvent metaKey Property - Javascript DOM

Javascript examples for DOM:Mouse Event

Description

The metaKey property indicates if the "META" key was pressed.

This property is read-only.

Return Value

A Boolean, indicating whether the "META" key was pressed

The following code shows how to find out whether or not the "META" key was pressed when a mouse button is clicked:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body onmousedown="isKeyPressed(event)">

<script>
function isKeyPressed(event) {/* w ww.j a  v a 2 s .c om*/
    if (event.metaKey) {
        console.log("The META key was pressed!");
    } else {
        console.log("The META key was NOT pressed!");
    }
}
</script>

</body>
</html>

Related Tutorials