@@ -36,7 +36,8 @@ Web apps are getting closer and closer to be desktop-class applications. With th
36
36
## Compatibility with Angular Versions
37
37
38
38
| @ngneat/hotkeys | Angular |
39
- | --------------- | ------- |
39
+ | -----------------| ---------|
40
+ | 3.x.x | >=17.2 |
40
41
| 2.x.x | >=16 |
41
42
| 1.3.x | >=14 |
42
43
| 1.2.x | <=13 |
@@ -47,6 +48,7 @@ Web apps are getting closer and closer to be desktop-class applications. With th
47
48
48
49
## Usage
49
50
51
+ ### Module
50
52
Add ` HotkeysModule ` in your ` AppModule ` :
51
53
52
54
``` ts
@@ -58,6 +60,17 @@ import { HotkeysModule } from '@ngneat/hotkeys';
58
60
export class AppModule {}
59
61
```
60
62
63
+ ### Standalone
64
+ Add ` HotkeysService ` in the standalone components :
65
+
66
+ ``` ts
67
+ @Component ({
68
+ standalone: true ,
69
+ imports: [HotkeysDirective ],
70
+ })
71
+ export class AppComponent {}
72
+ ```
73
+
61
74
Now you have two ways to start adding shortcuts to your application:
62
75
63
76
## Hotkeys Directive
@@ -137,7 +150,7 @@ interface Options {
137
150
}
138
151
```
139
152
140
- #### ` onShortcut `
153
+ ### ` onShortcut `
141
154
142
155
Listen to any registered hotkey. For example:
143
156
@@ -148,7 +161,7 @@ const unsubscribe = this.hotkeys.onShortcut((event, key, target) => console.log(
148
161
unsubscribe ();
149
162
```
150
163
151
- #### ` registerHelpModal `
164
+ ### ` registerHelpModal `
152
165
153
166
Display a help dialog listing all visible hotkeys:
154
167
@@ -175,14 +188,15 @@ export class AppComponent implements AfterViewInit {
175
188
```
176
189
177
190
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:
178
-
191
+ ```
179
192
<p align="center">
180
193
<img width="50%" height="50%" src="./help_screenshot.png">
181
194
</p>
195
+ ```
182
196
183
197
You can also provide a custom component. To help you with that, the service exposes the ` getShortcuts ` method.
184
198
185
- #### ` removeShortcuts `
199
+ ### ` removeShortcuts `
186
200
187
201
Remove previously registered shortcuts.
188
202
@@ -193,7 +207,7 @@ this.hotkeys.removeShortcuts('meta.a');
193
207
this .hotkeys .removeShortcuts ([' meta.1' , ' meta.2' ]);
194
208
```
195
209
196
- #### ` setSequenceDebounce `
210
+ ### ` setSequenceDebounce `
197
211
198
212
Set the number of milliseconds to debounce a sequence of keys
199
213
0 commit comments