KeyHandler example
This RSG 2.0 SDK app demonstrates the KeyHandler component: scoped key handling and key bubbling between nested handlers.
Purpose
This app shows how multiple nested KeyHandler components cooperate. Each handler declares which keys it consumes; keys that it does not claim bubble up to the parent handler. For every keypress, the app shows which handler handled it.
Summary
This example covers the following topics:
- Three nested handlers: Inner (
OK,Up, andDown), Modifier (dynamic key set), and Outer (handleAllKeys, which catches every key that bubbles up) - Reactive changes to a handler's
keysat runtime: pressPlayto cycle the keys that the Modifier handler claims through three modes, which changes what bubbles to Outer - A live readout of the last key, the press or release, and the handler that consumed it (color-coded)
Controls
You can use these remote control keys to explore key bubbling:
- OK, Up, and Down: Handled by Inner
- Play: Cycles the modifier key modes, which changes the bubbling behavior
- Any other key: Handled by Modifier (if claimed) or bubbles to Outer
Development
You can use these commands to build, test, and lint the example:
npx rk dev # Build + deploy to Roku device
pnpm test # Run tests
pnpm run lint # Lint sourcesUpdated about 4 hours ago
Did this page help you?