Create Custom Keyboard Shortcuts On Angular App

Author: milestechnologies
Publish Date:
Official Page: Go to website
Views Total: 49
License: MIT

Description:

A simple Angular directive/component to create custom keyboard shortcuts (hotkeys) on your Angular based applications.

How to use it:

1. Install the package.

# NPM
$ npm install ngx-keyboard-shortcuts --save

2. Import the module.

import { NgxKeyboardShortcutModule } from 'ngx-keyboard-shortcuts';

@NgModule({
imports: [NgxKeyboardShortcutModule.forRoot()]
})
export class AppModule {}

3. The example to create a shortcut (Ctrl+s).

<button [keyboardShortcut]="keyboardShortcutDef" (click)="example()">
  Click Me
</button>
keyboardShortcutDef: IKeyboardShortcutListenerOptions = {
  description: 'example',
  keyBinding: [KeyboardKeys.Ctrl, KeyboardKeys.Shift, 'i']
};

Preview:

Create Custom Keyboard Shortcuts On Angular App


Tags:

Add Comment