"use client"; import { useKeyboardShortcuts } from "@/hooks/use-keyboard-shortcuts"; import { Keyboard } from "lucide-react"; import { useState } from "react"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "./ui/dialog"; import { getPlatformSpecialKey } from "@/lib/utils"; const modifier: { [key: string]: string; } = { Shift: "Shift", Alt: "Alt", ArrowLeft: "←", ArrowRight: "→", ArrowUp: "↑", ArrowDown: "↓", Space: "Space", }; function getKeyWithModifier(key: string) { if (key === "Ctrl") return getPlatformSpecialKey(); return modifier[key] || key; } const ShortcutItem = ({ shortcut }: { shortcut: any }) => { // Filter out lowercase duplicates for display - if both "j" and "J" exist, only show "J" const displayKeys = shortcut.keys.filter((key: string) => { if ( key.includes("Cmd") && shortcut.keys.includes(key.replace("Cmd", "Ctrl")) ) return false; return true; }); return (
{shortcut.icon && (
{shortcut.icon}
)} {shortcut.description}
{displayKeys.map((key: string, index: number) => (
{key.split("+").map((keyPart: string, partIndex: number) => ( {getKeyWithModifier(keyPart)} ))}
{index < displayKeys.length - 1 && ( or )}
))}
); }; export const KeyboardShortcutsHelp = () => { const [open, setOpen] = useState(false); // Get shortcuts from centralized hook (disabled so it doesn't add event listeners) const { shortcuts } = useKeyboardShortcuts({ enabled: false }); const categories = Array.from(new Set(shortcuts.map((s) => s.category))); return ( Keyboard Shortcuts Speed up your video editing workflow with these keyboard shortcuts. Most shortcuts work when the timeline is focused.
{categories.map((category) => (

{category}

{shortcuts .filter((shortcut) => shortcut.category === category) .map((shortcut, index) => ( ))}
))}
); }; function ShortcutKey({ children }: { children: React.ReactNode }) { return ( {children} ); };