File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -363,9 +363,18 @@ function focusKeydown(event: KeyboardEvent) {
363
363
364
364
const shortcutListeners = new WeakMap ( )
365
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
+
366
375
function shortcut ( toolbar : Element , event : KeyboardEvent ) {
367
376
if ( ( event . metaKey && modifierKey === 'Meta' ) || ( event . ctrlKey && modifierKey === 'Control' ) ) {
368
- const button = toolbar . querySelector < HTMLElement > ( `[hotkey=" ${ event . key } "]` )
377
+ const button = findHotkey ( toolbar , event . key )
369
378
if ( button ) {
370
379
button . click ( )
371
380
event . preventDefault ( )
You can’t perform that action at this time.
0 commit comments