mirror of
https://github.com/infinilabs/coco-app.git
synced 2026-09-02 04:01:53 +02:00
* feat: networked search data sources support search and keyboard-only operation * docs: update changelog
25 lines
642 B
TypeScript
25 lines
642 B
TypeScript
import { modifierKeys } from "@/components/Settings/Advanced/components/Shortcuts";
|
|
import { useShortcutsStore } from "@/stores/shortcutsStore";
|
|
import { useKeyPress } from "ahooks";
|
|
|
|
export const useModifierKeyPress = () => {
|
|
const modifierKey = useShortcutsStore((state) => {
|
|
return state.modifierKey;
|
|
});
|
|
const setModifierKeyPressed = useShortcutsStore((state) => {
|
|
return state.setModifierKeyPressed;
|
|
});
|
|
|
|
useKeyPress(
|
|
modifierKeys,
|
|
(event, key) => {
|
|
if (key === modifierKey) {
|
|
setModifierKeyPressed(event.type === "keydown");
|
|
}
|
|
},
|
|
{
|
|
events: ["keydown", "keyup"],
|
|
}
|
|
);
|
|
};
|