Home > widget-integration > FilterController > setupKeydownEvent
FilterController.setupKeydownEvent() method
Sets up keyboard event listeners for filter interactions. Handles keyboard navigation for sort controls, view options, limit lists, and bundles.
Supports keyboard accessibility by responding to standard keys (Enter, Space, Arrow keys). Stores the key code in filter state for use by other handlers.
Signature:
setupKeydownEvent(): Promise<void>;
Returns:
Promise<void>
Remarks
This method enables keyboard-only navigation through filter controls, ensuring WCAG compliance for accessibility. The keydown events are captured on the filter document context to handle all keyboard interactions within the filter scope.
Example
Override to add custom keyboard shortcuts:
window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
return class CustomFilterController extends FilterController {
async setupKeydownEvent() {
await super.setupKeydownEvent();
// Add custom keyboard shortcut (e.g., 'F' to focus filter)
document.addEventListener('keydown', (e) => {
if (e.key === 'f' && e.ctrlKey) {
this.focusFilterInput();
}
});
}
};
});