Skip to content
Related Articles

Related Articles

Improve Article

jQuery event.metaKey Property

  • Last Updated : 08 Jul, 2020

The event.metaKey property in jQuery is used to identify whether the meta key is pressed or not. There are two examples discussed below.
Syntax:

event.metaKey

Return Value: It returns “true” if the key is meta key else it returns “false”.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Example 1: In this example, type in the <input> element and see the result.




<!DOCTYPE HTML>
<html>
  
<head>
    <title>
        jQuery event.metaKey Property
    </title>
  
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
      
    <p id="GFG_UP"></p>
  
    <input type="text" 
        onkeydown="Geeks(event)" />
  
    <p id="GFG_DOWN"></p>
  
    <script>
        var elUp = document.getElementById("GFG_UP");
        var elDown = document.getElementById("GFG_DOWN");
        elUp.innerHTML = "JQuery | event.metaKey property";
  
        function Geeks(event) {
            if (event.metaKey) {
                elDown.innerHTML = 
                    "The META key was pressed!";
            } else {
                elDown.innerHTML = 
                    "The META key was NOT pressed!";
            }
        
    </script>
</body>
  
</html>

Output:

Example 2: Press any button from anywhere in the document and see the result.




<!DOCTYPE HTML>
<html>
  
<head>
    <title>
        JQuery event.metaKey Property
    </title>
  
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
      
    <p id="GFG_UP"></p>
  
    <p id="GFG_DOWN"></p>
  
    <script>
        var elUp = document.getElementById("GFG_UP");
        var elDown = document.getElementById("GFG_DOWN");
        elUp.innerHTML = "JQuery | event.metaKey property";
          
        $('html').click(function (event) {
            if (event.metaKey) {
                elDown.innerHTML = 
                    "The META key was pressed!";
            } else {
                elDown.innerHTML = 
                    "The META key was NOT pressed!";
            }
        }); 
    </script>
</body>
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :