import type { KeyboardEvent } from 'react' /** * Enter/Space activate a non-native `role='button'` element (the accordion * title areas of `Legend.Row` / `Legend.Group`), like a real button. */ export function accordionKeyDown(toggle: () => void) { return (event: KeyboardEvent) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault() toggle() } } }