import { useEffect } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { X } from '../../lib/icons' import { SHORTCUTS, type ShortcutCategory } from '../../lib/player-shortcuts' import { usePreferencesStore } from '../../stores/preferences-store' interface Props { open: boolean onClose: () => void } const CATEGORY_LABELS: Record = { playback: 'Playback', audio: 'Audio', subtitles: 'Subtitles', tools: 'Tools', view: 'View', navigation: 'Navigation', } const CATEGORY_ORDER: ShortcutCategory[] = [ 'playback', 'audio', 'subtitles', 'view', 'tools', 'navigation', ] function prettyKey(binding: string): string[] { return binding.split('+').map(p => { if (p === ' ') return 'Space' if (p === 'ArrowLeft') return '←' if (p === 'ArrowRight') return '→' if (p === 'ArrowUp') return '↑' if (p === 'ArrowDown') return '↓' if (p === 'Escape') return 'Esc' return p }) } export default function KeyboardHints({ open, onClose }: Props) { const overrides = usePreferencesStore(s => s.keyboardShortcuts) useEffect(() => { if (!open) return function onKey(e: KeyboardEvent) { if (e.key === 'Escape' || e.key === '?') { e.preventDefault() onClose() } } window.addEventListener('keydown', onKey, true) return () => window.removeEventListener('keydown', onKey, true) }, [open, onClose]) return ( {open && ( e.stopPropagation()} className="bg-[#0c0a08]/96 backdrop-blur-2xl border border-white/14 rounded-2xl w-[640px] max-w-[88vw] max-h-[80vh] overflow-y-auto content-scroll shadow-[0_30px_80px_-20px_rgba(0,0,0,0.85)]" role="dialog" aria-label="Keyboard shortcuts" >

Keyboard shortcuts

{CATEGORY_ORDER.map(cat => { const items = SHORTCUTS.filter(s => s.category === cat) if (items.length === 0) return null return (

{CATEGORY_LABELS[cat]}

    {items.map(sc => { const keys = overrides[sc.id]?.length ? overrides[sc.id] : sc.keys return (
  • {sc.description} {prettyKey(keys[0]).map((k, i) => ( {k} ))}
  • ) })}
) })}
)}
) }