# ngx-hotkey

> An easy way to use Hotkeys in Angular.

Latest version **1.0.7** (published 2020-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-hotkey
pnpm add ngx-hotkey
yarn add ngx-hotkey
bun add ngx-hotkey
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-10-13 |
| First published | 2020-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 75.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Danilo Peres |
| Maintainers | daniloperes |
| Keywords | Angular, Shortcut, Shortcuts, hotkey, hotkeys, hotkeys for angular, shortcuts for angular |

## Links

- npm: https://www.npmjs.com/package/ngx-hotkey
- Repository: https://github.com/DaniloPeres/ngx-hotkey
- Homepage: https://github.com/DaniloPeres/ngx-hotkey#readme
- Issues: https://github.com/DaniloPeres/ngx-hotkey/issues
- npm.io page: https://npm.io/package/ngx-hotkey

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Recent versions

- 1.0.7 (latest) — 2020-10-13
- 1.0.6 — 2020-07-21
- 1.0.5 — 2020-07-20
- 1.0.4 — 2020-07-20
- 1.0.3 — 2020-07-20
- 1.0.2 — 2020-07-20
- 1.0.1 — 2020-07-20
- 1.0.0 — 2020-07-20
- 0.0.1 — 2020-07-20

## README

# ngx-hotkey

ngx-hotkey is an easy way to register shortcuts in Angular.

## Setup

### Installation

Install from npm repository:
```
npm install ngx-hotkey --save
 ```
--------------------
Include ngx-hotkey in Main Module and Feature Modules where you want to use the editor component.(eg: app.module.ts): 
```typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
...

import { NgxHotkeyService } from 'ngx-hotkey'; // <- Import the library
@NgModule({
  declarations: [...],
  imports: [...],
  providers: [
    ...
    NgxHotkeyService // <- Add this service
  ],
  bootstrap: [...]
})
export class AppModule {
}
```

## Sample

```typescript
import { Component, OnDestroy } from '@angular/core';
import { NgxHotkeyService } from 'ngx-hotkey';

@Component({
    selector: 'my-comp'
})
export class MyComp implements OnDestroy {

    constructor(private ngxHotKeyService: NgxHotkeyService) {
        this.ngxHotKeyService.add('ctrl+b', (event: KeyboardEvent) => {
            alert('ctrl+b pressed');
            return false;
        });
        this.ngxHotKeyService.add('control+a', (event: KeyboardEvent) => {
            alert('ctrl+a pressed');
            return false;
        });
        this.ngxHotKeyService.add('ctrl+shift+s', (event: KeyboardEvent) => {
            alert('ctrl+shift+a pressed');
            return false;
        });
    }

    ngOnDestroy() {
        // remove shortcuts
        this.ngxHotKeyService.remove('ctrl+b');
        this.ngxHotKeyService.remove('control+a');
        this.ngxHotKeyService.remove('ctrl+shift+s');
    }
}
```

## Author
Danilo Peres
danilo_meirelles@hotmail.com

## License

MIT © [Danilo Peres](https://github.com/daniloperes)

---
_Source: https://npm.io/package/ngx-hotkey · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
