forked from Github/frigate
Search UI tweaks (#13965)
* Prevent keyboard shortcuts from running when input is focused * fix reset button and update time pickers when using input * simplify css * consistent button order and spacing
This commit is contained in:
@@ -10,6 +10,7 @@ export type KeyModifiers = {
|
||||
export default function useKeyboardListener(
|
||||
keys: string[],
|
||||
listener: (key: string | null, modifiers: KeyModifiers) => void,
|
||||
preventDefault: boolean = true,
|
||||
) {
|
||||
const keyDownListener = useCallback(
|
||||
(e: KeyboardEvent) => {
|
||||
@@ -25,13 +26,13 @@ export default function useKeyboardListener(
|
||||
};
|
||||
|
||||
if (keys.includes(e.key)) {
|
||||
e.preventDefault();
|
||||
if (preventDefault) e.preventDefault();
|
||||
listener(e.key, modifiers);
|
||||
} else if (e.key === "Shift" || e.key === "Control" || e.key === "Meta") {
|
||||
listener(null, modifiers);
|
||||
}
|
||||
},
|
||||
[keys, listener],
|
||||
[keys, listener, preventDefault],
|
||||
);
|
||||
|
||||
const keyUpListener = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user