Use Focus Groups for Arrow Navigation
mainKeyUX provides a polyfill for the focusgroup attribute, allowing users to navigate groups of elements using arrow keys instead of just Tab.
Supported Attributes:
focusgroup: Marks a group for arrow navigation.focusgroup="block": Enables vertical arrow navigation.focusgroup="wrap": Enables cyclic focus movement (wraps around).focusgroup="no-memory": Prevents restoring the last focus position.focusgroup="none": Excludes the element from arrow navigation.
Note: grid functionality is not currently supported.
Setup:
Call focusGroupPolyfill() in startKeyUX and use focusGroupKeyUX() to enable arrow navigation for standard ARIA roles.
<div focusgroup="wrap">
<button type="button">Option 1</button>
<button type="button">Option 2</button>
</div>import { focusGroupPolyfill, focusGroupKeyUX, startKeyUX } from 'keyux'
startKeyUX(window, [
focusGroupKeyUX(),
focusGroupPolyfill()
])