Open In App

jQuery event.metaKey Property

Last Updated : 08 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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.




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



Similar Reads

HTML | DOM TouchEvent metaKey Property
The TouchEvent metaKey property is a read-only property and used for returning a Boolean value which indicates whether or not the "meta" key was pressed when a touch event triggered. It mostly returns false because generally, touch devices do not have a meta key. Syntax: event.metaKey Return Value: It returns true if the meta key is pressed, else i
2 min read
HTML | DOM KeyboardEvent metaKey Property
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 Pro
1 min read
jQuery event.timeStamp Property
The jQuery event.timeStamp is an inbuilt property that is used to measure the difference in milliseconds between the time of the event created by the browser and January 1, 1970. Syntax: event.timeStampParameter: It does not accept any parameter because it is a property, not a function. Example 1: This Example shows the working of an event.timeStam
2 min read
jQuery event.type Property
The jQuery event.type is an inbuilt property that is used to return which event type is started. Syntax: event.typeParameter: It does not accept any parameter because it is a property, not a function. Example 1: This example shows the working of an event.type property. C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src=
2 min read
jQuery event.pageX Property
The jQuery event.pageX is an inbuilt property which is used to find the position of the mouse pointer relative to the left edge of the document. Syntax: event.pageX Parameter: It does not accept any parameter because it is a property not a function. jQuery examples to show the working of event.pageX property: Example 1: In the below code, top left
2 min read
jQuery event.pageY Property
The jQuery event.pageY is an inbuilt property that is used to find the position of the mouse pointer relative to the top edge of the document. Syntax: event.pageY Parameter: It does not accept any parameter because it is a property not a function. jQuery examples to show the working of event.pageY property: Example 1: In the below code, bottom left
2 min read
jQuery event.which Property
The jQuery event.which is an inbuilt property in jQuery that is used to return which keyboard key or mouse button was pressed for the event. Syntax: event.whichParameter: It does not accept any parameter because it is a property, not a function. jQuery examples to show the working of this property:Example 1: In the below code, ascii value of the ke
2 min read
jQuery event.relatedTarget Property
The jQuery event.relatedTarget is an inbuilt property that is used to find which element is being entered or gets exit on mouse movement. Syntax: event.relatedTarget Parameter: It does not accept any parameter because it is a property not a function. Example 1: This example shows the working of event.relatedTarget property. C/C++ Code &lt;!DOCTYPE
2 min read
jQuery event.result Property
The jQuery event.result is an inbuilt property which is used to find the last and previous value returned by an event handler started by the specified event. Syntax: event.result Parameter: It does not accept any parameter because it is a property not a function. Example 1: jQuery code to show the working of event.result property. C/C++ Code &lt;!D
2 min read
jQuery event.target Property
The jQuery event.target is an inbuilt property that, is used to find which DOM element will start the event. Syntax: event.targetParameter: It does not accept any parameter because it is a property, not a function. Example 1: This example shows the working of event.target Property. C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;styl
2 min read