"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, Play, Pause, SkipBack, SkipForward } from "lucide-react";
interface Shortcut {
keys: string[];
description: string;
category: string;
icon?: React.ReactNode;
}
const shortcuts: Shortcut[] = [
// Playback Controls
{
keys: ["Space"],
description: "Play/Pause",
category: "Playback",
icon:
},
{
keys: ["J"],
description: "Rewind 1 second",
category: "Playback",
icon:
},
{
keys: ["K"],
description: "Play/Pause (alternative)",
category: "Playback",
icon:
},
{
keys: ["L"],
description: "Fast forward 1 second",
category: "Playback",
icon:
},
// Navigation
{
keys: ["←"],
description: "Frame step backward",
category: "Navigation"
},
{
keys: ["→"],
description: "Frame step forward",
category: "Navigation"
},
{
keys: ["Shift", "←"],
description: "Jump back 5 seconds",
category: "Navigation"
},
{
keys: ["Shift", "→"],
description: "Jump forward 5 seconds",
category: "Navigation"
},
{
keys: ["Home"],
description: "Go to timeline start",
category: "Navigation"
},
{
keys: ["End"],
description: "Go to timeline end",
category: "Navigation"
},
// Editing
{
keys: ["S"],
description: "Split element at playhead",
category: "Editing"
},
{
keys: ["Delete", "Backspace"],
description: "Delete selected elements",
category: "Editing"
},
{
keys: ["N"],
description: "Toggle snapping",
category: "Editing"
},
// Selection & Organization
{
keys: ["Cmd", "A"],
description: "Select all elements",
category: "Selection"
},
{
keys: ["Cmd", "D"],
description: "Duplicate selected element",
category: "Selection"
},
// History
{
keys: ["Cmd", "Z"],
description: "Undo",
category: "History"
},
{
keys: ["Cmd", "Shift", "Z"],
description: "Redo",
category: "History"
},
{
keys: ["Cmd", "Y"],
description: "Redo (alternative)",
category: "History"
}
];
const KeyBadge = ({ keyName }: { keyName: string }) => {
// Replace common key names with symbols
const displayKey = keyName
.replace("Cmd", "⌘")
.replace("Shift", "⇧")
.replace("←", "◀")
.replace("→", "▶")
.replace("Space", "⎵");
return (
{displayKey}
);
};
const ShortcutItem = ({ shortcut }: { shortcut: Shortcut }) => (
{shortcut.icon && (
{shortcut.icon}
)}
{shortcut.description}
{shortcut.keys.map((key, index) => (
{index < shortcut.keys.length - 1 && (
+
)}
))}
);
export const KeyboardShortcutsHelp = () => {
const [open, setOpen] = useState(false);
const categories = Array.from(new Set(shortcuts.map(s => s.category)));
return (
);
};