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

how to attach hotkey to action button in a form? #106

Open
chr1soscl opened this issue Apr 18, 2019 · 1 comment
Open

how to attach hotkey to action button in a form? #106

chr1soscl opened this issue Apr 18, 2019 · 1 comment
Labels

Comments

@chr1soscl
Copy link

I have a form which has buttons that call some actions on click, it gathers the event information which I use to save or perform other actions, I would like to use the hotkey as a button click, basically activate the click with a hotkey. this is a question.

Repository owner deleted a comment from omridevk May 29, 2019
@wittlock
Copy link
Collaborator

If you bind a method to the button-click:

<button (click)="doSomething()">

Then you could just call the same method when the hotkey is pressed:

this._hotkeysService.add(new Hotkey('shift+g', (event: KeyboardEvent): boolean => {
        doSomething();
        return false; // Prevent bubbling
    }));

Would that be sufficient to achieve what you want to do? Otherwise you could probably give your button a handle:

<button #myButton>

And I believe you will then be able to trigger an actual clickevent by in your hotkey method do something like myButton.click() (haven't tested it, but I think something along those lines would work).

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