Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkey to give focus to a field results as last hotkey beeing typed #1

Closed
clementprevot opened this issue Apr 2, 2014 · 2 comments
Closed
Assignees
Labels

Comments

@clementprevot
Copy link

Hi!

First of all, congrats for your work on this lib! It is really awesome.

I ran into a problem when setting an hotkey to give the focus to a field :

hotkeys.add({
            hotkey: 't a',
            description: 'Feel field',
            callback: function() {
                jQuery('#field').focus().val('');
            }
        });

When a press t and then a the field is correctly focused, but the a is typed inside the field, which I don't want.

Do you have any solution to solve this problem?

Thank you for your help

Regards

@chieffancypants
Copy link
Owner

Thanks for being brave and using it early! Though I hope to have this library wrapped up and out of experimental-use pretty soon.

This can be accomplished pretty easily by preventing the event from propagating:

hotkeys.add({
  hotkey: 't a',
  description: 'Feel field',
  callback: function(event) {
    event.preventDefault();
    jQuery('#field').focus().val('');
  }
});

@clementprevot
Copy link
Author

So obvious 😉

Thank you very much for your quick answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants