Keypad input device, why LV_EVENT_LONG_PRESSED only on ENTER?

I was surprised to find LONGPRESSED does not work for keypad devices except for a single key (KEY_ENTER). I’m not the only one who noticed that it seems like an unwanted limitation. The documentation does not really indicate this limitation either.

I don’t see why it has to be this way, or that it should but perhaps I don’t understand all the use cases. Thoughts on whether this can change?

Here is the relevant code:

        if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver->long_press_time) {
            i->proc.long_pr_sent = 1;
            if(data->key == LV_KEY_ENTER) {
                i->proc.longpr_rep_timestamp = lv_tick_get();
                lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, indev_act);
                if(indev_reset_check(&i->proc)) return;
            }
        }

It’s because ENTER is mapped to the touchpad-like events (PRESS, CLICK, RELEASE etc). So ENTER acts as you clicked the widgets via touchpad. If we sent the same events on LV_KEY_LEFT the widget would think the they were normally clicked.

I think we could solve it by having new events like LV_EVENT_KEY_PRESS/RELEASE/LONG_PRESS etc.

Any news ?

Not yet, it can part of v9 (planned for Q3/Q4 this year).

This is something I could definitely use right now. I have at least one hardware button I’m emulating as a keypad button that requires both long and short press behaviors. Is anyone planning on implementing this? I’m happy to assist.

1 Like

Hi, I think that short and long press in a hardware button actually works with LV_EVENT_SHORT_CLIKED and LV_EVENT_LONG_PRESSED.

I’m actually using It with a button attached to a GPIO0 on ESP32 in order to enter in light sleep mode or Deep sleep mode

If someone is is interested in working on it I’d be happy to discuss the details. Just let me know. :slight_smile: