Keyboard
Handle keyboard navigation input with ON_KEYBOARD_NEXT and ON_KEYBOARD_PREV.
Keyboard events fire when the user presses arrow keys during an active tour. These events are emitted only when keyboard control is enabled.
Events
| Event | String value | When |
|---|---|---|
ON_KEYBOARD_NEXT | keyboard:next | ArrowRight is pressed |
ON_KEYBOARD_PREV | keyboard:prev | ArrowLeft is pressed |
Usage
import { BordaEvent } from '@retoo/borda';
instance.api.events.on(BordaEvent.ON_KEYBOARD_NEXT, () => {
console.log('ArrowRight pressed');
});
instance.api.events.on(BordaEvent.ON_KEYBOARD_PREV, () => {
console.log('ArrowLeft pressed');
});
Notes
- Keypresses originating from form controls (
input,textarea,select,contenteditable) are ignored. - The Escape key emits
ON_TOUR_CLOSE, not a keyboard event. - Keyboard listeners are automatically removed on unmount.