The KeyboardEvent metaKey property in HTML DOM is a read-only property and is used to return a Boolean value which is used to check whether the META key is pressed or not. The KeyboardEvent metaKey property returns true if the META key is pressed, otherwise returns false.
Syntax:
event.metaKey
Below program illustrates the KeyboardEvent metakey Property in HTML DOM:
Example: This example check whether the META key is pressed or not.
<!DOCTYPE html> <html> <head> <title> HTML DOM KeyboardEvent metaKey Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2>KeyboardEvent metaKey Property</h2> <p> Check whether the META key is pressed or not </p> <input type="text" onkeydown="keyboard(event)"> <p id="test"></p> <!-- script to ckeck meta key pressed or not --> <script> function keyboard(event) { var a = document.getElementById("test"); if (event.metaKey) { a.innerHTML = "The META key has been pressed!"; } else { a.innerHTML = "The META key has not been pressed!"; } } </script> </body> </html> |
Output:
Before Press the key:

After Press the key:

Supported Web Browsers
- Opera
- Internet Explorer
- Google Chrome
- Firefox
- Apple Safari
Recommended Posts:
- HTML | DOM TouchEvent metaKey Property
- HTML | DOM KeyboardEvent shiftKey Property
- HTML | DOM KeyboardEvent code Property
- HTML | DOM keyboardEvent charCode Property
- HTML | DOM KeyboardEvent key Property
- HTML DOM | KeyboardEvent altKey Property
- HTML | DOM KeyboardEvent location Property
- HTML | DOM KeyboardEvent keyCode Property
- jQuery event.metaKey Property
- HTML | DOM KeyboardEvent getModifierState() Method
- HTML | DOM KeyboardEvent
- HTML | KeyboardEvent which Property
- HTML | DOM lang Property
- HTML | DOM Style backgroundClip Property
- HTML | DOM Style borderTop Property
- HTML | DOM Meter max Property
- HTML | DOM Input Hidden value Property
- HTML | DOM Textarea autofocus Property
- HTML | DOM Style columnGap Property
- HTML | DOM Input Time autofocus Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


