Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Arezth
Level 7

Centralized onKeyEvent or managing several

Hi Forum,

I was wondering about best practices...If I have several .brs that work as Screens, meaning each have a specific purpose and are called from a main scene, but I was wondering if it is better to have an onKeyEvent each screen or manage all the key events (centralized with many many validations) onthe main scene. I find it more tidy to have several onKeyEvents, but I've noticed that the onKeyevent on the main scene is always fired regardless if I have another in a secondary screen (brs).

What do you suggest?
0 Kudos
1 Reply
Roku Employee
Roku Employee

Re: Centralized onKeyEvent or managing several

Your issue is likely not returning `true` at the end of the first handler:
"onKeyEvent()" wrote:
The onKeyEvent() function must return true if the XML component handled the event, or false if it did not handle the event. Returning false allows the event to continue bubbling up the focus chain so that ancestors of the XML component can handle the event.
0 Kudos