"use client"; import { useEffect } from "react"; interface ShortcutItem { keys: string[]; description: string; } interface ShortcutGroup { title: string; shortcuts: ShortcutItem[]; } const isMac = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.userAgent); const modKey = isMac ? "⌘" : "Ctrl"; const shortcutGroups: ShortcutGroup[] = [ { title: "General", shortcuts: [ { keys: [`${modKey}`, "Enter"], description: "Run workflow" }, { keys: [`${modKey}`, "C"], description: "Copy selected nodes" }, { keys: [`${modKey}`, "V"], description: "Paste nodes / image / text" }, { keys: ["?"], description: "Show keyboard shortcuts" }, ], }, { title: "Add Nodes", shortcuts: [ { keys: ["Shift", "P"], description: "Add Prompt node" }, { keys: ["Shift", "I"], description: "Add Image Input node" }, { keys: ["Shift", "G"], description: "Add Generate Image node" }, { keys: ["Shift", "V"], description: "Add Generate Video node" }, { keys: ["Shift", "L"], description: "Add LLM Text node" }, { keys: ["Shift", "A"], description: "Add Annotation node" }, ], }, { title: "Layout (select 2+ nodes first)", shortcuts: [ { keys: ["V"], description: "Stack selected vertically" }, { keys: ["H"], description: "Stack selected horizontally" }, { keys: ["G"], description: "Arrange selected as grid" }, ], }, { title: "Canvas", shortcuts: [ { keys: ["Scroll"], description: "Zoom in / out" }, { keys: ["Trackpad"], description: "Pan (macOS)" }, { keys: ["Delete"], description: "Delete selected nodes" }, ], }, ]; function Kbd({ children }: { children: string }) { return ( {children} ); } interface KeyboardShortcutsDialogProps { isOpen: boolean; onClose: () => void; } export function KeyboardShortcutsDialog({ isOpen, onClose }: KeyboardShortcutsDialogProps) { useEffect(() => { if (!isOpen) return; const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape") { onClose(); } }; window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); }, [isOpen, onClose]); if (!isOpen) return null; return (
{/* Header */}

Keyboard Shortcuts

{/* Content */}
{shortcutGroups.map((group) => (

{group.title}

{group.shortcuts.map((shortcut, idx) => (
{shortcut.description}
{shortcut.keys.map((key, keyIdx) => ( {keyIdx > 0 && ( + )} {key} ))}
))}
))}
{/* Footer */}
); }