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

Is is possible to bind a keyboard shortcut to trigger the modal to open? #75

Open
puddicombe opened this issue Jan 9, 2016 · 1 comment

Comments

@puddicombe
Copy link

I think my client would save them a lot of time if they were able to use keyboard shortcuts on my app - and one of them would be to open an 'insert' modal with a shortcut.

But I can't work out how to bind a shortcut (which of course one can do to trigger a js function) to then open the modal. Am I missing something obvious?

@jpmelnik
Copy link

Try something like:

Template.TemplateName.rendered = function() {

var $this = this;

$(document).on('keypress', function(e) {
    if(!e.ctrlKey) {  // ctrl key
        return false;
    }
    //console.log(e.ctrlKey, e.keyCode, e.which)
    if(e.keyCode == 10 && e.which == 10) {  // enter key, or 13
        var el = $($this.firstNode).find('.button-to-click');
    el.trigger('click');
  }
});

};

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

No branches or pull requests

2 participants