# ngx-mousetrap

> An Angular library to use [mousetrap](https://www.npmjs.com/package/mousetrap) as Angular service or Angular Directive.

Latest version **13.0.0** (published 2021-11-18) · 0 weekly downloads

## Install

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

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 13.0.0 |
| Published | 2021-11-18 |
| First published | 2020-06-22 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 65.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | nagarsuresh |
| Keywords | mousetrap, ngx, angular |

## Links

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

## Dependencies (1)

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

## Recent versions

- 13.0.0 (latest) — 2021-11-18
- 12.0.0 — 2021-07-14
- 11.0.0 — 2021-04-16
- 10.0.0 — 2021-04-15
- 1.0.0 — 2020-06-22

## README

# NgxMousetrap

An Angular library to use [mousetrap](https://www.npmjs.com/package/mousetrap) as Angular service or Angular Directive.

## Getting Started

### Using as Directive
```
<button class="btn btn-primary"
  (click)="onClick()"
  [ngxMousetrapKey]="'command+enter | ctrl+enter'">
    Click or press (command/ctrl)+enter
</button>

```

When the keyboard shortcut is pressed, button will get clicked!

### Using as Angular Service
```
    const saveKey = 'command+s | ctrl+s'
    this.subscription = this.ngxMousetrapService.register(saveKey).
      subscribe(evt => {
        <!-- save hotkey pressed -->
      });

```

## Demo
https://nagarsuresh.github.io/ngx-mousetrap-angular/

## NPM
https://www.npmjs.com/package/ngx-mousetrap

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