Ignore key commands during text entry
This commit is contained in:
parent
cd2e91f5e1
commit
f7260974a5
@ -15,7 +15,15 @@ export default function useKeydownHandler({
|
||||
const { shouldRespondToKeyboardCommands } = useAppState();
|
||||
|
||||
const onKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (!keys || keys.some(key => key.toUpperCase() === e.key?.toUpperCase())) {
|
||||
const isKeyValid = (
|
||||
!keys ||
|
||||
keys.some(key => key.toUpperCase() === e.key?.toUpperCase())
|
||||
);
|
||||
const isTextEntry = (
|
||||
document.activeElement?.tagName === 'INPUT' ||
|
||||
document.activeElement?.tagName === 'TEXTAREA'
|
||||
);
|
||||
if (isKeyValid && !isTextEntry) {
|
||||
onKeyDownArg?.(e);
|
||||
}
|
||||
}, [onKeyDownArg, keys]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user