Skip to content

Commit

Permalink
Merge pull request #91 from Pilpin/master
Browse files Browse the repository at this point in the history
fix(release): bump all dependencies to latest

BREAKING CHANGE: Angular v17 is required
  • Loading branch information
NetanelBasal authored Mar 19, 2024
2 parents aac1fc2 + 26a6048 commit 1ff0709
Show file tree
Hide file tree
Showing 19 changed files with 9,562 additions and 8,583 deletions.
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Web apps are getting closer and closer to be desktop-class applications. With th
## Compatibility with Angular Versions

| @ngneat/hotkeys | Angular |
| --------------- | ------- |
|-----------------|---------|
| 3.x.x | >=17.2 |
| 2.x.x | >=16 |
| 1.3.x | >=14 |
| 1.2.x | <=13 |
Expand All @@ -47,6 +48,7 @@ Web apps are getting closer and closer to be desktop-class applications. With th

## Usage

### Module
Add `HotkeysModule` in your `AppModule`:

```ts
Expand All @@ -58,6 +60,17 @@ import { HotkeysModule } from '@ngneat/hotkeys';
export class AppModule {}
```

### Standalone
Add `HotkeysService` in the standalone components :

```ts
@Component({
standalone: true,
imports: [HotkeysDirective],
})
export class AppComponent {}
```

Now you have two ways to start adding shortcuts to your application:

## Hotkeys Directive
Expand Down Expand Up @@ -137,7 +150,7 @@ interface Options {
}
```

#### `onShortcut`
### `onShortcut`

Listen to any registered hotkey. For example:

Expand All @@ -148,7 +161,7 @@ const unsubscribe = this.hotkeys.onShortcut((event, key, target) => console.log(
unsubscribe();
```

#### `registerHelpModal`
### `registerHelpModal`

Display a help dialog listing all visible hotkeys:

Expand All @@ -175,14 +188,15 @@ export class AppComponent implements AfterViewInit {
```

It accepts a second input that allows defining the hotkey that should open the dialog. The default shortcut is `Shift + ?`. Here's how `HotkeysHelpComponent` looks like:

```
<p align="center">
<img width="50%" height="50%" src="./help_screenshot.png">
</p>
```

You can also provide a custom component. To help you with that, the service exposes the `getShortcuts` method.

#### `removeShortcuts`
### `removeShortcuts`

Remove previously registered shortcuts.

Expand All @@ -193,7 +207,7 @@ this.hotkeys.removeShortcuts('meta.a');
this.hotkeys.removeShortcuts(['meta.1', 'meta.2']);
```

#### `setSequenceDebounce`
### `setSequenceDebounce`

Set the number of milliseconds to debounce a sequence of keys

Expand Down
9 changes: 6 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "hotkeys:build"
"buildTarget": "hotkeys:build"
},
"configurations": {
"production": {
"browserTarget": "hotkeys:build:production"
"buildTarget": "hotkeys:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "hotkeys:build"
"buildTarget": "hotkeys:build"
}
},
"test": {
Expand Down Expand Up @@ -130,5 +130,8 @@
}
}
}
},
"cli": {
"analytics": false
}
}
Loading

0 comments on commit 1ff0709

Please sign in to comment.