Multi function key handle

Description

If my device is a music player, one key’s function is that click for next song and long press for volumn up. How can I handle it?

What MCU/Processor/Board and compiler are you using?

What LVGL version are you using?

What do you want to achieve?

What have you tried so far?

Code to reproduce

Screenshot and/or video

For different key,you can set a LV_EVENT_KEY event, then use lv_indev_get_key() to get the key.
For long press, set this event LV_EVENT_LONG_PRESSED.

If more keys pressed at same time, this flow is not good idea. I add 3 different events for key pressed/repeat/released.

How these keys are related to the UI? I mean do they press a specific button on the screen? Or working on all screens?

Maybe you should handle these key out of LVGL and if volume up is pressed change the value of a slider.

Or you can create transparent buttons on lv_layer_top() and use the LV_INDEV_TYPE_BUTTON type to make the physical buttons press the transparent buttons.

I have a combo key e.g. Up and Down. Or Long Press Right to enter menu. and click right key to turn on a Led. Key Up/Down click for next/previous song, Long for Volumn Up/Down.

In this case I’d go with LV_INDEV_TYPE_BUTTON.