angular2-hotkeys
angular2-hotkeys copied to clipboard
Request: Add directive
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 why not use ctrl+n
instead of charcodes?
I suggest a cleaner usage:
<button [angularHotKey]="ctrl+n">New Document</button>
this would be awesome! any plans?
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}"
)?
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).
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.
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