How to see which key was pressed with LV_EVENT_KEY event

Description

I can’t figure out how to actually retrieve which key was pressed in an event callback.

Specifically, I’m using a roller callback, and I get the events like LV_EVENT_KEY and LV_EVENT_PRESSED.

However, the callback signature of the even callback system has no means of passing in the actual event data. How do I retrieve that?

I see in lv_event_send_func that the input device’s callback gets the data at indev_act->driver.feedback_cb, but I don’t quite see the use of that – isn’t it the indev that sent the key in the first place?

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

Simulator

What LVGL version are you using?

github master branch cac6f92964f3cdb960612b21a7e7996af2a9e8ee

What do you want to achieve?

Get the key value so that I can pop out of a menu when a particular key is pressed.

What have you tried so far?

looked through the code and I can’t find how I’m supposed to retrieve the actual key pressed value.

Ah, I think I found the solution. Dig deeper into the forums… Looks like lv_event_get_data() gets the event data as a void pointer.

1 Like

I updated the docs to described this: https://github.com/lvgl/docs/commit/d37ddc48262a056fa1528a06dbe1999dde63788f