// The "?" cheat sheet: every keyboard shortcut for the page you are on, plus the ones that work everywhere. import { useEffect, useRef } from 'react'; import { useApp } from '../context/AppContext.js'; import { themeVars } from './reader/readerThemes.js'; const GLOBAL = [ ['⌘K / Ctrl K', 'Search and go to a passage'], ['?', 'Show this list'], ['Esc', 'Close whatever is open'], ]; const BY_PAGE = { reader: [ ['← →', 'Previous / next chapter'], ['/', 'Search this chapter or the whole Bible'], ['G', 'Pick a book and chapter'], ['B', 'Bookmark the selected verse'], ['C', 'Compare translations'], ['M', 'Map this chapter’s cross-references (needs IQ Bible)'], ['H', 'Your highlights'], [',', 'Reading settings'], ['F', 'Hide or show the controls'], ], study: [ ['← →', 'Previous / next chunk'], ['1 2 3', 'Write in Observe / Interpret / Apply'], ['Esc', 'Leave a note box (then keys work again)'], ['C W X P R', 'Commentary / Word study / Cross-refs / People & places / Reading list'], ['V', 'Compare passages or translations'], ], }; export default function ShortcutsHelp({ onClose }) { const { readerTheme, currentPage } = useApp(); const closeRef = useRef(null); useEffect(() => { const from = document.activeElement; closeRef.current?.focus(); const onKey = (e) => { if (e.key === 'Escape' || e.key === '?') { e.preventDefault(); e.stopPropagation(); onClose(); } }; document.addEventListener('keydown', onKey, true); return () => { document.removeEventListener('keydown', onKey, true); if (from instanceof HTMLElement && document.contains(from)) from.focus({ preventScroll: true }); }; }, [onClose]); const page = BY_PAGE[currentPage] ?? []; const section = (title, rows) => (

{title}

{rows.map(([keys, what]) => (
{keys}
{what}
))}
); return (
{ if (e.target === e.currentTarget) onClose(); }}>

Keyboard shortcuts

{page.length > 0 && section(currentPage === 'reader' ? 'In the Bible' : 'In this study', page)} {section('Everywhere', GLOBAL)}
); }