jQuery event.metaKey Property

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”.

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.