Enter key now loads track

This commit is contained in:
patben8 committed 2026-09-25 13:43:40 +02:00
1 parent 88737f2b08
commit 0fd5d56a4e
2 files changed
+15 -2

No files matched your search

+13 -1
View File
@@ -451,7 +451,8 @@ export function TrackTable({
// Keyboard: ↑/↓ move the selection (Shift extends it), Cmd/Ctrl+A selects
// every visible row, Esc clears, Delete/Backspace removes (where the view
// allows it). Read through a ref so the listener is attached once.
// allows it), Enter loads the highlighted row into the deck and plays it.
// Read through a ref so the listener is attached once.
// ←/→, Space, C and digits belong to the deck (PrepStrip).
const keysRef = useRef<(e: KeyboardEvent) => void>(() => {})
keysRef.current = (e) => {
@@ -476,6 +477,17 @@ export function TrackTable({
selection.onChange(new Set())
return
}
if (e.key === 'Enter' && onPlay) {
// The highlighted row is the lead — the one last clicked or arrowed to,
// which in a multi-selection is the row the cursor is on.
const lead = indexOf(leadRef.current)
if (lead < 0 || !selection.selected.has(rows[lead].original.id)) return
// Wins over a focused button, as Space does for the deck: after clicking
// a playlist and arrowing down, Enter must not re-press that playlist.
e.preventDefault()
if (!e.repeat) onPlay(rows[lead].original)
return
}
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
e.preventDefault()
const lead = indexOf(leadRef.current)