Dynamic input device type, BUTTON and KEYPAD functionallity

Hello. I have 5 physical switches for my display, and I use a button matrix on each screen to show their functions—which vary by screen. On some screens I need the buttons to act as a KEYPAD for UI navigation (e.g., changing values), on others I need them to trigger callbacks directly (e.g., switching screens or running functions), and sometimes a mix of both.

My first try was to configure the indev as KEYPAD type and catch LV_EVENT_KEY, but that only works if the key event goes to the focused element—which is impractical. My second attempt was to configure the indev as BUTTON type and programmatically call lv_group_focus_next() and simulate key presses; however, that approach feels sluggish and loses built-in features like automatic focus outlines.

How could this best be solved, if possible?