'use client'; import * as React from 'react'; import { Card } from './Card'; import { Button } from './Button'; import { X, Keyboard } from 'lucide-react'; import { cn } from '@/lib/utils/cn'; export interface Shortcut { key: string; description: string; modifier?: 'ctrl' | 'shift'; } const shortcuts: Shortcut[] = [ { key: '/', description: 'Focus search' }, { key: 'Esc', description: 'Clear search / Close dialog' }, { key: 'D', description: 'Toggle dark mode', modifier: 'ctrl' }, { key: '?', description: 'Show keyboard shortcuts', modifier: 'shift' }, ]; export function KeyboardShortcutsHelp() { const [isOpen, setIsOpen] = React.useState(false); React.useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === '?' && e.shiftKey) { e.preventDefault(); setIsOpen(true); } if (e.key === 'Escape' && isOpen) { setIsOpen(false); } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [isOpen]); if (!isOpen) { return ( ); } return (

Keyboard Shortcuts

{shortcuts.map((shortcut, i) => (
{shortcut.description}
{shortcut.modifier && ( {shortcut.modifier === 'ctrl' ? '⌘/Ctrl' : 'Shift'} )} {shortcut.key}
))}
); }