OscarGodson / jKey

Key shortcuts made simple
http://oscargodson.github.com/jKey/
185 stars 40 forks source link

Command key on OS X prevents keyup (Safari, Chrome, FF) #29

Open criedel opened 9 years ago

criedel commented 9 years ago

If you bind a combo like ctrl+enter on OS X, hold down the commend key and any other button (enter for example) you are able to “freeze” that button jKey's activeKeys array: Let go of the enter button while still holding the command button; you'll notice that no keyup event was fired for the enter button. Thus the activeKeys array within still contains the pressed enter key. Now you can trigger the ctrl+enter combo callback whenever you hit ctrl – no need to hit enter anymore, since it's registered as 'activeKey' forever... well until you hit enter again.

$(document).jkey('ctrl+enter',function(){
  jkey.log('You pressed the enter+ctrl key.');
});

That also makes combos with the command button impossible. I also noticed that jkey binds the keyCode 224 for the command button but it's different in all the browsers:

Firefox: 224 Opera: 17 WebKit (Safari/Chrome): 91 (Left Apple) or 93 (Right Apple)