Find out whether or not the "META" key was pressed when a mouse button is clicked:
<!DOCTYPE html> <html> <body onmousedown="isKeyPressed(event)"> <p>Click somewhere in the document. </p> <p id="demo"></p> <script> function isKeyPressed(event) {//from www .jav a 2 s . com if (event.metaKey) { document.getElementById("demo").innerHTML = "The META key was pressed!"; } else { document.getElementById("demo").innerHTML = "The META key was NOT pressed!"; } } </script> </body> </html>
The metaKey property returns a Boolean value that indicates whether or not the "META" key was pressed when a mouse event was triggered.
On Mac keyboards, the META key is represented by the the "Command/Cmd" key.
This property is read-only.