All Projects → brtnshrdr → Angular2 Hotkeys

brtnshrdr / Angular2 Hotkeys

Licence: mit
Keyboard shortcuts for Angular 2 apps

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Angular2 Hotkeys

Origami
Angular + Polymer
Stars: ✭ 158 (-11.73%)
Mutual labels:  angular2
Winhue
Controlling the Philips Hue lighting system from your Windows PC.
Stars: ✭ 167 (-6.7%)
Mutual labels:  hotkeys
Augury
Angular Debugging and Visualization Tools
Stars: ✭ 2,050 (+1045.25%)
Mutual labels:  angular2
Ngx Gauge
A highly customizable Gauge component for Angular 9+ apps and dashboards
Stars: ✭ 158 (-11.73%)
Mutual labels:  angular2
Onemore
A OneNote add-in with simple, yet powerful and useful features
Stars: ✭ 163 (-8.94%)
Mutual labels:  hotkeys
Ngx Daterangepicker Material
Pure Angular 2+ date range picker with material design theme, a demo here:
Stars: ✭ 169 (-5.59%)
Mutual labels:  angular2
Mydaterangepicker
Angular 2+ date range picker
Stars: ✭ 157 (-12.29%)
Mutual labels:  angular2
Ahkdll
AutoHotkey_H
Stars: ✭ 177 (-1.12%)
Mutual labels:  hotkeys
Angular Google Maps
Angular 2+ Google Maps Components
Stars: ✭ 1,982 (+1007.26%)
Mutual labels:  angular2
Angular Notifier
A well designed, fully animated, highly customizable, and easy-to-use notification library for your Angular application.
Stars: ✭ 175 (-2.23%)
Mutual labels:  angular2
Angular Development With Primeng
Code samples from the book "Angular UI Development with PrimeNG"
Stars: ✭ 159 (-11.17%)
Mutual labels:  angular2
Ngx Qrcode
An Angular 9/10 Component Library for Generating QR (Quick Response) Codes
Stars: ✭ 161 (-10.06%)
Mutual labels:  angular2
Ngx Inline Editor
Native UI Inline-editor Angular (4.0+) component
Stars: ✭ 172 (-3.91%)
Mutual labels:  angular2
Ngx Mqtt
This library isn't just a wrapper around MQTT.js for angular. It uses observables and takes care of subscription handling and message routing.
Stars: ✭ 157 (-12.29%)
Mutual labels:  angular2
Ionic2 Rating
⭐️ Angular star rating bar. Built for Ionic 2+.
Stars: ✭ 177 (-1.12%)
Mutual labels:  angular2
Hotkeys
🤖 A declarative library for handling hotkeys in Angular applications
Stars: ✭ 158 (-11.73%)
Mutual labels:  hotkeys
1backend
Run your web apps easily with a complete platform that you can install on any server. Build composable microservices and lambdas.
Stars: ✭ 2,024 (+1030.73%)
Mutual labels:  angular2
Ngx Socket Io
Socket.IO module for Angular
Stars: ✭ 178 (-0.56%)
Mutual labels:  angular2
Ngx Wig
Angular(...Angular 7, Angular 8, Angular 9, Angular 10, Angular 11) WYSIWYG HTML Rich Text Editor (from ngWig - https://github.com/stevermeister/ngWig)
Stars: ✭ 178 (-0.56%)
Mutual labels:  angular2
Angular Truffle Starter Dapp
Angular CLI + Truffle Starter Dapp; write, compile & deploy smart contracts on Ethereum blockchains
Stars: ✭ 174 (-2.79%)
Mutual labels:  angular2

angular2-hotkeys

Angular 9 and Ivy Compatible. Older versions might work but isn't officially tested.

Installation

To install this library, run:

$ npm install angular2-hotkeys --save

Examples

First, import the HotkeyModule into your root AppModule

import {HotkeyModule} from 'angular2-hotkeys';

Then, add HotkeyModule.forRoot() to your AppModule's import array

@NgModule({
    imports : [CommonModule, HotkeyModule.forRoot(), ...],
})
export class AppModule {}

If you have any sub/feature modules that also use hotkeys, import the HotkeyModule (but NOT .forRoot())

@NgModule({
    imports : [CommonModule, HotkeyModule, ...],
})
export class SharedModule {}

Then inject the service into your constructor and add a new hotkey

constructor(private _hotkeysService: HotkeysService) {
    this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean => {
        console.log('Typed hotkey');
        return false; // Prevent bubbling
    }));
}

It also handles passing an array of hotkey combinations for a single callback

this._hotkeysService.add(new Hotkey(['meta+shift+g', 'alt+shift+s'], (event: KeyboardEvent, combo: string): ExtendedKeyboardEvent => {
    console.log('Combo: ' + combo); // 'Combo: meta+shift+g' or 'Combo: alt+shift+s'
    let e: ExtendedKeyboardEvent = event;
    e.returnValue = false; // Prevent bubbling
    return e;
}));

Your callback must return either a boolean or an "ExtendedKeyboardEvent".

For more information on what hotkeys can be used, check out https://craig.is/killing/mice

This library is a work in progress and any issues/pull-requests are welcomed! Based off of the angular-hotkeys library

Cheat Sheet

To enable the cheat sheet, simply add <hotkeys-cheatsheet></hotkeys-cheatsheet> to your top level component template. The HotkeysService will automatically register the ? key combo to toggle the cheat sheet.

NB! Only hotkeys that have a description will apear on the cheat sheet. The Hotkey constructor takes a description as an optional fourth parameter as a string or optionally as a function for dynamic descriptions.

this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean => {
    console.log('Secret message');
    return false;
}, undefined, 'Send a secret message to the console.'));

The third parameter, given as undefined, can be used to allow the Hotkey to fire in INPUT, SELECT or TEXTAREA tags.

Cheat Sheet Customization

  1. You can now pass in custom options in HotkeyModule.forRoot(options: IHotkeyOptions).
export interface IHotkeyOptions {
  /**
   * Disable the cheat sheet popover dialog? Default: false
   */
  disableCheatSheet?: boolean;
  /**
   * Key combination to trigger the cheat sheet. Default: '?'
   */
  cheatSheetHotkey?: string;
  /**
   * Use also ESC for closing the cheat sheet. Default: false
   */
  cheatSheetCloseEsc?: boolean;
  /**
   * Description for the ESC key for closing the cheat sheet (if enabed). Default: 'Hide this help menu'
   */
  cheatSheetCloseEscDescription?: string;
  /**
   * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu'
   */
  cheatSheetDescription?: string;
};
  1. You can also customize the title of the cheat sheet component.
<hotkeys-cheatsheet title="Hotkeys Rock!"></hotkeys-cheatsheet>
<!-- Default: 'Keyboard Shortcuts:' -->

TODO

  1. Create unit and E2E tests

Development

To generate all * }.js, *.js.map and *.d.ts files:

$ npm run tsc

License

MIT © Nick Richardson

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].