diff --git a/CLAUDE.md b/CLAUDE.md
index 9af126d..73d8bfb 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -893,7 +893,7 @@ Two independent apps that talk over HTTP:
/ Try again (`backend_restart`). The shell has no timeout of its own. Before
ready it answers quit requests itself — nothing can be unsaved — and stops
at ready so it never races `QuitGuard`), `SaveBar` (+ "Discard changes…" when
- dirty, and the settings gear beside it, whose menu opens `ShortcutsDialog` — the shortcut list is written out BY HAND, so a new or changed shortcut in `PrepStrip` / `TrackTable` must be added there too — and `AppSettings` ("Konduktor Settings…": app-level prefs, each with its default in `APP_SETTING_DEFAULTS` and read through `useAppSetting`; today `expandPlaylistFolders` and `exportRootFolder`, both default off — the latter read by the backend at `run_export` and passed down as `ExportPayload.root_folder`. The Sidebar holds folder open state as per-id overrides of that setting, reset on a new library or a change of the setting, and carried to the new ids when a rename/move changes a folder's path id)), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
+ dirty, and the settings gear beside it, whose menu (or `?` anywhere) opens `ShortcutsDialog` — a KEYBOARD MAP (decided 2026-10-15): keys lit in the colour of what they do, a caption explaining the key pointed at or pressed (pressing explains, it never acts: a capture-phase listener keeps the deck's and table's keys from firing), holding or picking ⇧ / Cmd-Ctrl / Alt relights it with that layer, mouse gestures listed beneath. It shrinks to fit the dialog and drops the words on the keys when too small. Its content is `lib/shortcuts.ts`, written out BY HAND, so a new or changed shortcut in `PrepStrip` / `TrackTable` must be added there too — and `AppSettings` ("Konduktor Settings…": app-level prefs, each with its default in `APP_SETTING_DEFAULTS` and read through `useAppSetting`; today `expandPlaylistFolders` and `exportRootFolder`, both default off — the latter read by the backend at `run_export` and passed down as `ExportPayload.root_folder`. The Sidebar holds folder open state as per-id overrides of that setting, reset on a new library or a change of the setting, and carried to the new ids when a rename/move changes a folder's path id)), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
`TrackTable` (**the one track list** — All Tracks, playlists, exports and
devices. TanStack Table + **virtualized** grid; per-row play button,
configurable columns, header sorting, inline double-click editing, and
diff --git a/frontend/src/components/SettingsMenu.tsx b/frontend/src/components/SettingsMenu.tsx
index e9d8929..c0143eb 100644
--- a/frontend/src/components/SettingsMenu.tsx
+++ b/frontend/src/components/SettingsMenu.tsx
@@ -38,6 +38,25 @@ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
return () => document.removeEventListener('mousedown', onDoc)
}, [open])
+ // The `?` key opens the shortcut map from anywhere — unless typing, or
+ // something already holds the keyboard. Pressed as it is, no Shift: by its
+ // position (the US/UK "/ ?" key), and by the character on layouts that put
+ // `?` elsewhere (typed with Shift there).
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.metaKey || e.ctrlKey || e.altKey) return
+ if (!(e.code === 'Slash' && !e.shiftKey) && e.key !== '?') return
+ const t = e.target as HTMLElement | null
+ if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT' || t.isContentEditable)) return
+ if (document.querySelector('[aria-modal="true"], [role="menu"]')) return
+ e.preventDefault()
+ setOpen(false)
+ setShowShortcuts(true)
+ }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [])
+
const item =
'flex w-full flex-col items-start rounded-[10px] px-2.5 py-1.5 text-left hover:bg-ink-800'
@@ -122,7 +141,7 @@ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
className={item}
>
View Shortcuts
- Every keyboard shortcut in one list
+ Every keyboard shortcut, on a keyboard (?)
)}
diff --git a/frontend/src/components/ShortcutsDialog.tsx b/frontend/src/components/ShortcutsDialog.tsx
index 84bd1e5..082bac5 100644
--- a/frontend/src/components/ShortcutsDialog.tsx
+++ b/frontend/src/components/ShortcutsDialog.tsx
@@ -1,112 +1,167 @@
import { createPortal } from 'react-dom'
-import { useEffect } from 'react'
+import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
import { useCaps } from '../lib/capabilities'
+import { Icon } from '../lib/icons'
+import {
+ ARROW_GAP,
+ ARROW_KEYS,
+ AREA_COLORS,
+ AREAS,
+ KEY_ROWS,
+ KEYBOARD_UNITS,
+ KEYS_BY_CODE,
+ LAYER_NAMES,
+ LAYERS,
+ MODIFIER_KEY,
+ MOUSE,
+ bindings,
+ modifierLayer,
+ padRange,
+ unusedNote,
+ type Area,
+ type Binding,
+ type KeyDef,
+ type Layer,
+ type MouseGesture,
+} from '../lib/shortcuts'
interface Props {
onClose: () => void
}
-// Cmd on macOS, Ctrl elsewhere — the handlers accept either, but a list that
-// says "Cmd/Ctrl" everywhere is harder to scan than one that names your key.
-const IS_MAC = /Mac|iPhone|iPad/.test(navigator.userAgent)
-const MOD = IS_MAC ? '⌘' : 'Ctrl'
-const ALT_KEY = IS_MAC ? '⌥' : 'Alt'
+/** Key unit bounds, px. The map shrinks to fit the dialog; below LABEL_MIN the
+ * words on the keys go (the caption still explains each key), below SHORT_MIN
+ * the long modifier legends become symbols. */
+const UNIT_MAX = 52
+const UNIT_MIN = 20
+const LABEL_MIN = 44
+const SHORT_MIN = 38
-type Row = { keys: string[][]; action: string }
-type Section = { title: string; rows: Row[] }
+const ALL_AREAS = Object.keys(AREAS) as Area[]
+const matchText = (b: Binding) => `${b.text} ${b.label}`.toLowerCase()
+const mouseText = (r: MouseGesture) => `${r.gesture} ${r.on ?? ''} ${r.text}`.toLowerCase()
-/** Hotcue keys are digits in pad order, 0 being the tenth, so the list follows
- * the loaded library's bank size rather than hard-coding eight. */
-function hotcueKeys(slots: number): string {
- const n = Math.min(slots, 10)
- if (n <= 0) return '1'
- if (n <= 9) return `1–${n}`
- return '1–9, 0'
-}
-
-function sections(slots: number): Section[] {
- const pads = hotcueKeys(slots)
- return [
- {
- title: 'Deck',
- rows: [
- { keys: [['Space']], action: 'Play / pause' },
- { keys: [['C']], action: 'CUE — jump back, set, or hold to preview' },
- { keys: [['←'], ['→']], action: 'Beat jump back / forward — or move the loop, while one plays' },
- { keys: [[MOD, '↓'], [MOD, '↑']], action: 'Halve / double the loop and jump size' },
- { keys: [['Shift', '←'], ['Shift', '→']], action: 'Previous / next grid marker' },
- { keys: [[pads]], action: 'Hotcue — set if empty, else jump (hold to preview)' },
- { keys: [['Shift', pads]], action: 'Delete hotcue' },
- { keys: [['Q'], ['W'], ['E'], ['R']], action: 'Stem track: mute / unmute stem 1–4' },
- { keys: [['Shift', 'Q–R']], action: 'Stem track: solo — mute every other stem (again to unmute all)' },
- { keys: [[ALT_KEY, 'Click', 'stem']], action: 'Solo a stem from its lane button' },
- { keys: [['Drag waveform']], action: 'Scratch' },
- { keys: [[MOD, 'Scroll']], action: 'Zoom the waveform' },
- { keys: [['Right-click', 'pad']], action: 'Hotcue type, rename, delete' },
- ],
- },
- {
- title: 'Track list',
- rows: [
- { keys: [['Enter']], action: 'Load and play the highlighted track' },
- { keys: [['↑'], ['↓']], action: 'Move the selection' },
- { keys: [['Shift', '↑'], ['Shift', '↓']], action: 'Extend the selection' },
- { keys: [[MOD, 'A']], action: 'Select all' },
- { keys: [['Esc']], action: 'Clear the selection' },
- { keys: [['Delete']], action: 'Remove from this playlist' },
- { keys: [['Shift', 'Click']], action: 'Select a range' },
- { keys: [[MOD, 'Click']], action: 'Add to / remove from the selection' },
- { keys: [['Double-click']], action: 'Edit a cell' },
- { keys: [['Right-click']], action: 'Track menu (header: choose columns)' },
- { keys: [['Drag rows']], action: 'Onto a playlist or export to add, onto the deck to load, within a playlist to reorder' },
- { keys: [[ALT_KEY, 'Drag']], action: 'Move tracks to another playlist (out of this one)' },
- { keys: [['Esc']], action: 'While dragging: cancel the drag' },
- ],
- },
- {
- title: 'Sidebar',
- rows: [
- { keys: [['Right-click']], action: 'New playlist or folder, rename, delete' },
- { keys: [['Drag']], action: 'Rearrange playlists and folders; onto an export to add one' },
- ],
- },
- {
- title: 'Fields & dialogs',
- rows: [
- { keys: [['Enter']], action: 'Save the edit / confirm' },
- { keys: [['Esc']], action: 'Cancel / close' },
- ],
- },
- ]
-}
-
-function Keys({ combo }: { combo: string[] }) {
- return (
-
- {combo.map((k, i) => (
-
- {k}
-
- ))}
-
- )
-}
-
-/** Every keyboard shortcut (and the mouse gestures that go with them), from the
- * settings menu. Keep in step with the handlers in `PrepStrip` and `TrackTable`
- * — this list is written out by hand, not derived from them. */
+/** Every shortcut, drawn on a keyboard: a key lights in the colour of what it
+ * does, pointing at (or pressing) it explains it, and holding a modifier — or
+ * picking one above — relights the map with that layer. Mouse gestures are
+ * listed beneath. The content lives in `lib/shortcuts.ts`. */
export function ShortcutsDialog({ onClose }: Props) {
const slots = useCaps().cues.hotcue_slots
+ const binds = useMemo(() => bindings(slots), [slots])
+ const [sticky, setSticky] = useState('base')
+ const [held, setHeld] = useState>(new Set())
+ const [hover, setHover] = useState(null)
+ const [pressed, setPressed] = useState(null)
+ const [query, setQuery] = useState('')
+ const [areas, setAreas] = useState>(new Set(ALL_AREAS))
+ const layer: Layer = held.has('mod') ? 'mod' : held.has('alt') ? 'alt' : held.has('shift') ? 'shift' : sticky
+ const q = query.trim().toLowerCase()
+
+ // ---- fit: one key unit from the width the map has ----
+ const fitRef = useRef(null)
+ const [unit, setUnit] = useState(UNIT_MAX)
+ useLayoutEffect(() => {
+ const el = fitRef.current
+ if (!el) return
+ const fit = () => {
+ const u = Math.floor(el.clientWidth / KEYBOARD_UNITS)
+ setUnit(Math.max(UNIT_MIN, Math.min(UNIT_MAX, u)))
+ }
+ fit()
+ const ro = new ResizeObserver(fit)
+ ro.observe(el)
+ return () => ro.disconnect()
+ }, [])
+
+ // ---- keyboard: pressing a key explains it rather than doing it ----
+ // Capture phase on window, so the deck's and the table's own listeners (which
+ // are on window too, bubbling) never see a key pressed in here.
+ const queryRef = useRef(query)
+ queryRef.current = query
useEffect(() => {
- const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
- window.addEventListener('keydown', onKey)
- return () => window.removeEventListener('keydown', onKey)
+ let release: number | undefined
+ const onDown = (e: KeyboardEvent) => {
+ const inField = (e.target as HTMLElement | null)?.tagName === 'INPUT'
+ if (e.key === 'Escape') {
+ e.preventDefault()
+ e.stopPropagation()
+ if (inField && queryRef.current) setQuery('')
+ else onClose()
+ return
+ }
+ if (inField) return
+ const mod = modifierLayer(e.code)
+ if (mod) {
+ setHeld((h) => new Set(h).add(mod))
+ return
+ }
+ if (e.code === 'Tab' || !KEYS_BY_CODE[e.code]) return
+ e.stopPropagation()
+ // Space / Enter still press a focused control (a layer tab, a modifier key).
+ const t = e.target as HTMLElement | null
+ if ((e.code === 'Space' || e.code === 'Enter') && t?.tagName === 'BUTTON' && !t.dataset.mapKey) return
+ e.preventDefault()
+ setHover(e.code)
+ setPressed(e.code)
+ window.clearTimeout(release)
+ release = window.setTimeout(() => setPressed(null), 160)
+ }
+ const onUp = (e: KeyboardEvent) => {
+ const mod = modifierLayer(e.code)
+ if (mod) {
+ setHeld((h) => {
+ const next = new Set(h)
+ next.delete(mod)
+ return next
+ })
+ } else if (KEYS_BY_CODE[e.code] && (e.target as HTMLElement | null)?.tagName !== 'INPUT') {
+ e.stopPropagation() // the deck's keyup ends a held cue/hotcue preview
+ }
+ }
+ const onBlur = () => setHeld(new Set())
+ window.addEventListener('keydown', onDown, true)
+ window.addEventListener('keyup', onUp, true)
+ window.addEventListener('blur', onBlur)
+ return () => {
+ window.clearTimeout(release)
+ window.removeEventListener('keydown', onDown, true)
+ window.removeEventListener('keyup', onUp, true)
+ window.removeEventListener('blur', onBlur)
+ }
}, [onClose])
+ const visible = (l: Layer, code: string) => (binds[l][code] ?? []).filter((b) => areas.has(b.area))
+ const layerCount = (l: Layer) =>
+ Object.values(binds[l]).flat().filter((b) => areas.has(b.area) && (!q || matchText(b).includes(q))).length +
+ MOUSE.flatMap((c) => c.rows).filter((r) => (r.mod ?? 'base') === l && (!q || mouseText(r).includes(q))).length
+
+ const pickLayer = (l: Layer) => setSticky((s) => (s === l && l !== 'base' ? 'base' : l))
+ const toggleArea = (a: Area) =>
+ setAreas((cur) => {
+ const next = new Set(cur)
+ if (next.has(a) && next.size > 1) next.delete(a)
+ else next.add(a)
+ return next
+ })
+
+ const gap = Math.max(2, Math.round(unit / 10))
+ const keyProps = {
+ unit,
+ gap,
+ labels: unit >= LABEL_MIN,
+ short: unit < SHORT_MIN,
+ layer,
+ hover,
+ pressed,
+ q,
+ visible,
+ noted: (code: string) => !!unusedNote(code, slots),
+ bound: (code: string) => LAYERS.some((l) => binds[l][code]),
+ onHover: setHover,
+ onPick: pickLayer,
+ }
+
return createPortal(