4.0.0 • Published 2 years ago

@balticcode/ngx-hotkeys v4.0.0

Weekly downloads
329
License
Apache-2.0
Repository
github
Last release
2 years ago

npm version

ngx-hotkeys

An Angular module providing hotkey support.

Feel free to take a look at the DEMO.

Introduction

This module started as an updated port of angular2-hotkeys which originates from a personal need of a full Angular 6 compatible version. The original library was the last dependency forcing us to use the rxjs-compat.

Installation

Install via npm:

npm install @balticcode/ngx-hotkeys --save

Usage

Import NgxHotkeysModule

import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {NgxHotkeysModule} from '@balticcode/ngx-hotkeys';

@NgModule({
    imports: [
        BrowserModule,
        NgxHotkeysModule.forRoot()
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Configuration (NgxHotkeysModule.forRoot(options?: HotkeyOptions))
  • disableCheatSheet
    • Type: boolean?
    • Disable the cheat sheet popover dialog.
    • Default: false
  • cheatSheetTitle
    • Type: string?
    • Specify the cheat sheets title.
    • Default: 'Keyboard Shortcuts:'
  • cheatSheetHotkey
    • Type: string?
    • Key combination to trigger the cheat sheet.
    • Default: '?'
  • cheatSheetHotkeyDescription
    • Type: string?
    • Description for the cheat sheet hot key in the cheat sheet.
    • Default: 'Show / hide this help menu'
  • cheatSheetCloseEsc
    • Type: boolean?
    • Use also ESC for closing the cheat sheet
    • Default: false
  • cheatSheetCloseEscDescription

    • Type: string?
    • Description for the ESC key for closing the cheat sheet (if enabled).
    • Default: 'Hide this help menu'

API

NgxHotkeysService

Methods

  • register(hotkey: Hotkey | Hotkey[], unpausing = false): void: Registers a new hotkey/new hotkeys with it's/their handler(s).
  • unregister(hotkey: Hotkey | Hotkey[], pausing = false): void: Removes a/the registered hotkey(s).
  • get(combo?: string): Hotkey | Hotkey[]: Returns all hotkeys matching the passed combo(s).
  • pause(hotkey?: Hotkey | Hotkey[]): void: Stops listening for the specified hotkeys.
  • unpause(hotkey?: Hotkey | Hotkey[]): void: Resumes listening for the specified hotkeys.
  • reset(): void: Resets all hotkeys.

Properties

  • hotkeys (Hotkey[]): Returns the registered hotkeys as array.
  • cheatSheetToggled (Observable<boolean>): Returns an Observable stream indicating the cheatsheets visibility was toggled.
  • options (HotkeyOptions): Returns the options used to configure the service.
Example
import {Hotkey, NgxHotkeysService} from '@balticcode/ngx-hotkeys';

constructor(private _hotkeysService: NgxHotkeysService) {
  this._hotkeysService.register({
    combo: 'shift+g',
    handler: event => {
      console.log('Typed hotkey');
    },
    description: 'Sends a secret message to the console.'
  });
}

NgxCheatsheetComponent

Properties

  • title (string): Determines the Cheatsheet title.
4.0.0

2 years ago

3.0.2

4 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago