Fix: event listener interference with input typing
This commit is contained in:
parent
8cb7b5186b
commit
e0170aedd6
|
@ -55,9 +55,21 @@ const KeyPressListener: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Function to handle keydown events
|
// Function to handle keydown events
|
||||||
const handleKeyPress = (event: KeyboardEvent) => {
|
const handleKeyPress = (event: KeyboardEvent) => {
|
||||||
// Allow default behavior for F5 and F12
|
|
||||||
const keyCombination = detectModifierKeys(event);
|
|
||||||
|
|
||||||
|
const activeElement = document.activeElement;
|
||||||
|
|
||||||
|
const isTyping =
|
||||||
|
activeElement instanceof HTMLInputElement ||
|
||||||
|
activeElement instanceof HTMLTextAreaElement ||
|
||||||
|
(activeElement && activeElement.getAttribute('contenteditable') === 'true');
|
||||||
|
|
||||||
|
if (isTyping) {
|
||||||
|
return; // Don't trigger shortcuts while typing
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyCombination = detectModifierKeys(event);
|
||||||
|
|
||||||
|
// Allow default behavior for F5 and F12
|
||||||
if (["F5", "F11", "F12"].includes(event.key) || keyCombination === "Ctrl+R") {
|
if (["F5", "F11", "F12"].includes(event.key) || keyCombination === "Ctrl+R") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue