@@ -31,7 +31,7 @@ const UseRegisterShortcutProvider = ({
31
31
} : UseRegisterShortcutProviderType ) => {
32
32
const disableShortcutsRef = useRef < boolean > ( false )
33
33
const shortcutsRef = useRef < Record < string , ShortcutType > > ( { } )
34
- const keysDownRef = useRef < Set < string > > ( new Set ( ) )
34
+ const keysDownRef = useRef < Set < Uppercase < string > > > ( new Set ( ) )
35
35
const keyDownTimeoutRef = useRef < ReturnType < typeof setTimeout > > ( - 1 )
36
36
const ignoredTags = ignoreTags ?? IGNORE_TAGS_FALLBACK
37
37
@@ -116,38 +116,37 @@ const UseRegisterShortcutProvider = ({
116
116
} , [ ] )
117
117
118
118
const handleKeydownEvent = useCallback ( ( event : KeyboardEvent ) => {
119
- if ( keyDownTimeoutRef . current === - 1 ) {
120
- keyDownTimeoutRef . current = setTimeout ( ( ) => {
121
- handleKeyupEvent ( )
122
- } , shortcutTimeout ?? DEFAULT_TIMEOUT )
123
- }
124
-
125
119
if ( preventDefault ) {
126
120
event . preventDefault ( )
127
121
}
128
122
129
123
if (
130
124
ignoredTags . map ( ( tag ) => tag . toUpperCase ( ) ) . indexOf ( ( event . target as HTMLElement ) . tagName . toUpperCase ( ) ) >
131
- - 1
125
+ - 1 ||
126
+ disableShortcutsRef . current
132
127
) {
133
128
return
134
129
}
135
130
136
- if ( ! disableShortcutsRef . current ) {
137
- keysDownRef . current . add ( event . key . toUpperCase ( ) )
131
+ keysDownRef . current . add ( event . key . toUpperCase ( ) as Uppercase < string > )
138
132
139
- if ( event . ctrlKey ) {
140
- keysDownRef . current . add ( 'CONTROL' )
141
- }
142
- if ( event . metaKey ) {
143
- keysDownRef . current . add ( 'META' )
144
- }
145
- if ( event . altKey ) {
146
- keysDownRef . current . add ( 'ALT' )
147
- }
148
- if ( event . shiftKey ) {
149
- keysDownRef . current . add ( 'SHIFT' )
150
- }
133
+ if ( event . ctrlKey ) {
134
+ keysDownRef . current . add ( 'CONTROL' )
135
+ }
136
+ if ( event . metaKey ) {
137
+ keysDownRef . current . add ( 'META' )
138
+ }
139
+ if ( event . altKey ) {
140
+ keysDownRef . current . add ( 'ALT' )
141
+ }
142
+ if ( event . shiftKey ) {
143
+ keysDownRef . current . add ( 'SHIFT' )
144
+ }
145
+
146
+ if ( keyDownTimeoutRef . current === - 1 ) {
147
+ keyDownTimeoutRef . current = setTimeout ( ( ) => {
148
+ handleKeyupEvent ( )
149
+ } , shortcutTimeout ?? DEFAULT_TIMEOUT )
151
150
}
152
151
} , [ ] )
153
152
0 commit comments