AnitaTang / js-hotkeys

Automatically exported from code.google.com/p/js-hotkeys
0 stars 0 forks source link

Command key on Macs #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
js-hotkjeys 0.7.9 does not support the meta modifier, which is the 
Command/Apple key on Mac 
OS X. The following patch adds support for this. I have tested this with 
Command-Z on Firefox 
3.5.3 and Safari 4.0.3, it works on both.

--- spool/jquery.hotkeys.js     Sat Sep 26 01:28:26 2009
+++ spool/jquery.hotkeys.meta.js        Sat Sep 26 01:23:18 2009
@@ -182,6 +182,7 @@
                 // prevent f5 overlapping with 't' (or f4 with 's', etc.)
                 character = !special && String.fromCharCode(code).toLowerCase(),
                 shift = event.shiftKey,
+                meta = event.metaKey,
                 ctrl = event.ctrlKey,            
                 // patch for jquery 1.2.5 && 1.2.6 see more at:  
                 // http://groups.google.com/group/jquery-
en/browse_thread/thread/83e10b3bb1f1c32b
@@ -199,7 +200,7 @@
             if (mapPoint){ 
                 var trigger;
                 // event type is associated with the hkId
-                if(!shift && !ctrl && !alt) { // No Modifiers
+                if(!shift && !meta && !ctrl && !alt) { // No Modifiers
                     trigger = mapPoint[special] ||  (character && mapPoint[character]);
                 }
                 else{
@@ -206,6 +207,7 @@
                     // check combinations (alt|ctrl|shift+anything)
                     var modif = '';
                     if(alt) modif +='alt+';
+                    if(meta) modif+= 'meta+';
                     if(ctrl) modif+= 'ctrl+';
                     if(shift) modif += 'shift+';
                     // modifiers + special keys or modifiers + character or modifiers + shift character or 
just shift character

Original issue reported on code.google.com by fazalma...@gmail.com on 26 Sep 2009 at 8:30

GoogleCodeExporter commented 8 years ago
Never mind, this is a duplicate of issue #31

Original comment by fazalma...@gmail.com on 26 Sep 2009 at 8:32