/** * Index of the tab that a key moves focus to in a horizontal tab list, or * null when the key is not a tab-list key. Arrows wrap around; Home and End * jump to the ends (WAI-ARIA Authoring Practices, tabs pattern). */ export function tabKeyTarget(key: string, index: number, count: number): number | null { if (count <= 0) return null; switch (key) { case "ArrowRight": return (index + 1) % count; case "ArrowLeft": return (index - 1 + count) % count; case "Home": return 0; case "End": return count - 1; default: return null; } }