"use client"; import { useState } from "react"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "./ui/dialog"; import { Badge } from "./ui/badge"; import { Keyboard } from "lucide-react"; import { useKeyboardShortcuts } from "@/hooks/use-keyboard-shortcuts"; const KeyBadge = ({ keyName }: { keyName: string }) => { // Replace common key names with symbols or friendly names const displayKey = keyName .replace("Cmd", "⌘") .replace("Shift", "Shift") .replace("ArrowLeft", "Arrow Left") .replace("ArrowRight", "Arrow Right") .replace("ArrowUp", "Arrow Up") .replace("ArrowDown", "Arrow Down") .replace("←", "◀") .replace("→", "▶") .replace("Space", "Space"); return ( {displayKey} ); }; 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) => { const lowerKey = key.toLowerCase(); const upperKey = key.toUpperCase(); // If this is a lowercase letter and the uppercase version exists, skip it if ( key === lowerKey && key !== upperKey && shortcut.keys.includes(upperKey) ) { return false; } return true; }); return (
{shortcut.icon && (
{shortcut.icon}
)} {shortcut.description}
{displayKeys.map((key: string, index: number) => (
{key.split("+").map((keyPart: string, partIndex: number) => (
{partIndex < key.split("+").length - 1 && ( + )}
))}
{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) => ( ))}
))}
); };