(e: KeyboardEvent)
| 67 | // Keyboard nav — j/k move within the currently-displayed order. |
| 68 | useEffect(() => { |
| 69 | function onKey(e: KeyboardEvent) { |
| 70 | if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return |
| 71 | if (e.metaKey || e.ctrlKey || e.altKey) return |
| 72 | if (e.key !== 'j' && e.key !== 'k') return |
| 73 | if (ordered.length === 0) return |
| 74 | const idx = ordered.findIndex((x) => x.id === selectedId) |
| 75 | const next = e.key === 'j' ? Math.min(ordered.length - 1, idx + 1) : Math.max(0, idx - 1) |
| 76 | if (next !== idx && ordered[next]) selectAndRead(ordered[next]!.id) |
| 77 | } |
| 78 | window.addEventListener('keydown', onKey) |
| 79 | return () => window.removeEventListener('keydown', onKey) |
| 80 | // eslint-disable-next-line react-hooks/exhaustive-deps |
nothing calls this directly
no test coverage detected