Open In App
Related Articles

How to check whether the META key pressed when event is fired using jQuery ?

Like Article
Save Article
Report issue

jQuery is a feature-rich JavaScript library. It is a fast and most used JavaScript library. Before using jQuery you must have a basic knowledge of HTML, CSS, and JavaScript.

In this article, we will learn about how you can check whether the META key was pressed when the event fired JQuery.

META key: It is a special key that is located next to the space bar on the keyboard. The different operating system, it is located at different location example – 

  • Windows – The META key maps to the Windows key.
  • Macintosh –  the META key maps to the Command key (⌘).

event.metaKey: It will return a boolean value (true or false) that indicates whether the META key was pressed at the time the event fired or not. 

Example: In this example, we are using the above-explained method.


<!doctype html>
<html lang="en">
        h1 {
            color: green;
        body {
            background-color: lightgreen;
            text-align: center;
        div {
            padding: 20px;
        p {
            font-size: 25px;
        button {
            background-color: #4CAF50;
            /* Green */
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
    <script src=
        Click here to check whether
        Meta key was pressed of not.
    <button value="Test" name="Test" id="check">
        click Here!!
    <h1 style="color:black;" id="display">
        $("#check").click(function (event) {



  • Before clicking the button – There is only one button named ‘click me please!’. 
  • After clicking the button: After clicking the button if you see true then it indicates that you did press a meta key but in case, you can notice that your output is false it indicates that you didn’t press any meta key.


Last Updated : 06 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Similar Reads