You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevents the shortcut's callback from being executing on registering of duplicated shortcuts
When registering a duplicated shortcut, the `addShortcut` and
`addSequenceShortcut` methods return `of(null)` which immediately emits on
subscribe. In case of duplicated shortcuts, we instead return EMPTY which
doesn't emit and completes immediately on subscribe.
@@ -191,6 +196,7 @@ export class AppComponent implements AfterViewInit {
191
196
```
192
197
193
198
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:
@@ -251,44 +257,28 @@ The pipe accepts and additional parameter the way key combinations are separated
251
257
252
258
It is also possible to alias keys to custom strings. For example, the macos key for enter is `⌤`. To display it as `Enter`, you can use the following:
253
259
254
-
```html
260
+
````html
255
261
<divclass="help-dialog-shortcut-key">
256
262
<kbd[innerHTML]="hotkey.keys | hotkeysShortcut: '-' : ' then ': {enter: 'Enter'}"></kbd>
257
263
</div>
258
264
259
-
```html
260
-
261
-
## Allowing hotkeys in form elements
262
-
263
-
By default, the library prevents hotkey callbacks from firing when their event originates from an `input`, `select`, or `textarea` element or any elements that are contenteditable. To enable hotkeys in these elements, specify them in the `allowIn` parameter:
@@ -300,6 +290,8 @@ That's all for now! Make sure to check out the `playground` inside the `src` [fo
300
290
301
291
No. It'snotpossibletodefineahotkeymultipletimes.Eachhotkeyhasadescriptionandagroup,soitdoesn't make sense assigning a hotkey to different actions.
302
292
293
+
In case of registering duplicated hotkeys, the `addShortcut` and `addSequenceShortcut` methods return an `EMPTY` observable, allowing to detect duplicated hotkeys registration and execute custom logic.
294
+
303
295
**Why am I not receiving any event?**
304
296
305
297
If you'veaddedahotkeytoaparticularelementofyourDOM,makesureit's focusable. Otherwise, hotkeys cannot capture any keyboard event.
0 commit comments