jQuery event.metaKey Property

Last Updated:

jQuery event.metaKey Property

The jQuery event.metaKey property indicates whether the META key was pressed when the event fired.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery event.metaKey Property</h1> <p>Hold 'meta' key and click on me</p> <p>In Windows OS 'Window' button is a metakey</p> <p>In Mac OS 'cmd(⌘)' button is a metakey</p> <script> $(document).ready(function(){ $("p:first-of-type").mousedown(function(e){ if(e.metaKey) alert("You Pressed metaKey"); else alert("metaKey was not pressed."); }); }); </script> </body> </html>

Syntax

event.metaKey;

Return Value

Value Explanation
true If the meta key was pressed.
false If the meta key was not pressed.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
event.metaKeyYesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author