Ignore key commands during text entry

This commit is contained in:
Sam Becker 2025-04-27 09:53:28 -05:00
parent cd2e91f5e1
commit f7260974a5

View File

@ -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]);