Open In App

HTML | DOM KeyboardEvent metaKey Property

Last Updated : 06 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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. 

html




<!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 12.1
  • Internet Explorer 9
  • Google Chrome 1
  • Edge 12
  • Firefox 1.5
  • Apple Safari 1.2


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads