We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a561e30 + a20936d commit 4849a95Copy full SHA for 4849a95
src/index.ts
@@ -363,9 +363,18 @@ function focusKeydown(event: KeyboardEvent) {
363
364
const shortcutListeners = new WeakMap()
365
366
+function findHotkey(toolbar: Element, key: string): HTMLElement | null {
367
+ for (const el of toolbar.querySelectorAll<HTMLElement>('[hotkey]')) {
368
+ if (el.getAttribute('hotkey') === key) {
369
+ return el
370
+ }
371
372
+ return null
373
+}
374
+
375
function shortcut(toolbar: Element, event: KeyboardEvent) {
376
if ((event.metaKey && modifierKey === 'Meta') || (event.ctrlKey && modifierKey === 'Control')) {
- const button = toolbar.querySelector<HTMLElement>(`[hotkey="${event.key}"]`)
377
+ const button = findHotkey(toolbar, event.key)
378
if (button) {
379
button.click()
380
event.preventDefault()
0 commit comments