diff --git a/frontend/src/components/CommandPalette.tsx b/frontend/src/components/CommandPalette.tsx index 8b67721..60b192b 100644 --- a/frontend/src/components/CommandPalette.tsx +++ b/frontend/src/components/CommandPalette.tsx @@ -26,6 +26,7 @@ import { import { PartyIcon } from "@hugeicons/core-free-icons" import { useUser } from "@/context/UserContext" import { useCelebration } from "@/hooks/useTaskCelebration" +import { useMetaHotkey } from "@/hooks/use-hotkey" interface CommandPaletteProps { open: boolean @@ -343,18 +344,7 @@ export function CommandPalette({ */ export function useCommandPalette() { const [open, setOpen] = useState(false) - - useEffect(() => { - const handleKeyDown = (e: KeyboardEvent) => { - if ((e.metaKey || e.ctrlKey) && e.key === "k") { - e.preventDefault() - setOpen((prev) => !prev) - } - } - - document.addEventListener("keydown", handleKeyDown) - return () => document.removeEventListener("keydown", handleKeyDown) - }, []) - + const toggle = useCallback(() => setOpen((prev) => !prev), []) + useMetaHotkey("k", toggle) return { open, setOpen } } diff --git a/frontend/src/components/ShortcutHelpDialog.tsx b/frontend/src/components/ShortcutHelpDialog.tsx index ce78bfe..763d80d 100644 --- a/frontend/src/components/ShortcutHelpDialog.tsx +++ b/frontend/src/components/ShortcutHelpDialog.tsx @@ -6,39 +6,14 @@ import { DialogDescription, } from "@/components/ui/dialog" import { Kbd } from "@/components/ui/kbd" +import { groupShortcuts } from "@/lib/shortcut-registry" interface ShortcutHelpDialogProps { open: boolean onOpenChange: (open: boolean) => void } -const shortcuts = [ - { - group: "Global", - items: [ - { keys: ["⌘", "K"], description: "Open command palette" }, - { keys: ["?"], description: "Show keyboard shortcuts" }, - { keys: ["⇧", "T"], description: "Celebrate" }, - ], - }, - { - group: "Navigation", - items: [ - { keys: ["G", "D"], description: "Go to Dashboard" }, - { keys: ["G", "P"], description: "Go to Projects" }, - { keys: ["G", "T"], description: "Go to Tasks" }, - { keys: ["G", "M"], description: "Go to Team" }, - ], - }, - { - group: "Project Detail", - items: [{ keys: ["T"], description: "Create new task" }], - }, - { - group: "Task Detail", - items: [{ keys: ["A"], description: "Add assignee" }], - }, -] +const shortcuts = groupShortcuts() export function ShortcutHelpDialog({ open, @@ -62,7 +37,7 @@ export function ShortcutHelpDialog({