Skip to main content

ng-keyboard-shortcut

<ng-keyboard-shortcut> component can help you create a single shortcut, in a more declarative way. Each component added can be bound to one shortcut, and will emit using (fire) Output binding when the shortcut is clicked. Can be useful to create multiple shortcut, each shortcut will be added to the Help menu automatically as long as you provide a description and a label.

Example


<ng-keyboard-shortcut *ngIf="enableShortcut" [key]="'shift + k'" (fire)="onShiftPlusKClicked($event)"></ng-keyboard-shortcut>

Inputs:

NameTypeDefaultDescription
keystring / string[] noneList or single key (sequencese or combinations) to bind to.
descriptionstring""the description to show in the help menu
labelstring""the label to group the key in the help menu
preventDefaultbooleanfalsewhether to prevent default of the original key fired
targetHTMLElementundefinedLimit the event to a specific target
allowInAllowIn[]Keys are disable for Input, Select, ContentEditable and Textarea, this can be used to allow the shortcut to work in those elements
throttleTimenumber0Throttle the key event