Reputation: 41
I recently tried the js-hotkeys plugin (http://code.google.com/p/js-hotkeys/), and found it really useful for making hotkeys.
Problem is: That it seems like the original '.keyup()', '.keydown()' and '.keypress()' gets overidden by the plugin.
Now I have to listen for ANY key presses in an input field, but since I can't use the original jQuery functions, my guess is that I have to use the plugin, but I can't figure out how.
It doesn't seem like I can leave the second parameter (the one where I specify the key-combination) empty, and the documentation says nothing about any "Listen for any key"-option.
Anyone got any ideas?
Upvotes: 0
Views: 341
Reputation: 21
I'm pretty sure that you are mistaken about that - I have been working with the hotkeys plugin for some time now and if you look at the top of the code you will note that the prototype is saving the original functionality for .bind. If you think about it, disabling the native behavior would cause a whole slew of problems since you wouldn't be able to perform .bind method for all other events either.
You should be able to do
$('#foo').bind('keyup', function(event)
{
if(event.which == 13) // return key
{
$(this).trigger('click'); // or console.log / whatever
}
});
Please don't be offended but I think you're simply coding it up wrong. If you can send me your code, I would be happy to help you debug - but I can tell you without reservation that your hotkeys plugin is NOT disabling the jQuery .bind method. If it is, then it is different than the one I have and I would be happy to send along a link to a functional one.
Good luck.
Upvotes: 2