Previous example is accessible (and theoretically WCAG 2.1 AA compliant), but for full ARIA compliance, full keyboard navigation is needed.
See sample code for example of how to do these 'keydown' event checks and processing.
- Don't mark your menu with
role = "menubar"
and items withrole = "menuitem"
unless you are implementing the full ARIA specification. Instead, simply make sure your accordion set is inside a NAV element wrapper.