OscarGodson / jKey

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

Key Combos Firing when one key is pressed #19

Closed cfletcher1856 closed 12 years ago

cfletcher1856 commented 12 years ago

First I would like to thank you for this plugin, it saved me tons of time and headaches.
My issue is i am tracking when someone pastes into an input field. The key combo i set up is 'crtl+v' which works the first time you press it. Then after that anytime you press a v or crtl it will fire the callback function.

I made a fiddle for you with my code.

http://jsfiddle.net/cfletcher1856/zTPtv/

OscarGodson commented 12 years ago

@cfletcher1856 You can't use alerts. Alerts take the focus off the element (in this case a textarea) and therefore the keyup event never fires on that element. So, it thinks you still have ctrl pressed because you lifted it when the focus was lost. This is why the demo uses a custom console to demo it.

If you swap it to a normal console log it will work: http://jsfiddle.net/zTPtv/1/

cfletcher1856 commented 12 years ago

wonderful, thanks :+1: