Find out whether or not the "META" key was pressed when a keyboard key is pressed:
Press a key on the keyboard in the input field to find out if the META key was pressed or not.
<!DOCTYPE html> <html> <body> <input type="text" onkeydown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) {//from www.j ava2 s. c o m var x = document.getElementById("demo"); if (event.metaKey) { x.innerHTML = "The META key was pressed!"; } else { x.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 key event was triggered.
On Mac keyboards, the META key is represented by the the "Command/Cmd" key.
This property is read-only.
Possible values: