Lv_keyboard to serial monitor


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


What LVGL version are you using?


What do you want to achieve?

I want to make the lv_keyboard to be displayed in serial monitor when typed and entered. I’ve been trying to find codes and instructions to make it but I failed and I need some help.

void ta_event_cb(lv_event_t *e)
    // Cast the target object to lv_obj_t pointer
    lv_obj_t * ta = (lv_obj_t *)lv_event_get_target(e);

    // Check if the key is pressed
    if (lv_event_get_code(e) == LV_EVENT_PRESSED) {
        const char * text = lv_textarea_get_text(ta);
        Serial.print(text); // Print the word entered

void lv_example_keyboard_1(void)
    // Create a screen
    lv_obj_t * scr = lv_disp_get_scr_act(NULL);

    // Create a keyboard to use it with one of the text areas
    lv_obj_t * kb = lv_keyboard_create(scr);

    // Create a text area
    lv_obj_t * ta = lv_textarea_create(scr);
    lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 10);
    lv_obj_set_size(ta, lv_pct(90), 80);
    lv_obj_add_state(ta, LV_STATE_FOCUSED);

    // Set the keyboard's text area
    lv_keyboard_set_textarea(kb, ta);

    // Assign event callback to the text area
    lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_PRESSED, NULL);