angular2-hotkeys icon indicating copy to clipboard operation
angular2-hotkeys copied to clipboard

Request: Add directive

Open JavanXD opened this issue 7 years ago • 6 comments

By adding a directive hotkeys could be easily linked for examle to a button.

<button [angularHotKey]="[17,78]">New Document</button>
<!-- CTRL = 17 & n = 78 -->

JavanXD avatar Sep 06 '17 14:09 JavanXD

@JavanXD why not use ctrl+n instead of charcodes? I suggest a cleaner usage: <button [angularHotKey]="ctrl+n">New Document</button>

Misiu avatar Sep 28 '17 11:09 Misiu

this would be awesome! any plans?

rui-cruz avatar Oct 03 '17 02:10 rui-cruz

If this does move forward there would have to be a better definition of the intended behaviour. Would it be based on context (e.g. form = submit(), button = click(), input = focus())? Would it support a key/callback syntax (e.g. [angularHotKey]="{'ctrl+n': myFunction}")?

DAquilina avatar Oct 26 '17 20:10 DAquilina

Sorry. I'm not currently adding any new functionality to the project myself, as I no longer work with angular for my job. I'd love a pull request after the intended behavior is discussed (I think this would also solve other people's scope problems).

brtnshrdr avatar Oct 27 '17 21:10 brtnshrdr

I quite like this idea. It's a nice convenience "shortcut" for the simpler hotkey needs. Adding a directive to a button to be equivalent of a click could just as well be accomplished with a global hotkey, button as a @ViewChild and then trigger the click-event. But a directive would be clean.

I like @DAquilina idea of tying the behavior to the element it's attached to, trigger a click on a button, submitting a form or focusing an input. I'm not sure allowing a callback makes much sense because wouldn't that be equivalent to just declaring it in the component.ts file? I think that would be a good start at least.

wittlock avatar Mar 28 '18 22:03 wittlock

this is an awesome idea, I am looking for the same functionality, but I suppose after one year this enhancement has not been implemented yet. <button [angularHotKey]="ctrl+n">New Document

chr1soscl avatar Apr 23 '19 18:04 chr1soscl