# lv_keyboard.h (/api/widgets/keyboard/lv_keyboard_h)



<RelatedHeaders name="lv_keyboard_private.h" isPrivate="false" />

<ApiSummary functions="12" enums="2" macros="1" variables="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (4)&#x22;,&#x22;Getters (6)&#x22;,&#x22;Other (2)&#x22;]">
  <ApiTab value="Setters (4)">
    <ApiMember kind="function" name="lv_keyboard_set_textarea" file="widgets/keyboard/lv_keyboard.h" line="76" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L76">
      lv_keyboard_set_textarea [#lv_keyboard_set_textarea]

      Assign a text area to the keyboard. Pressed characters will be inserted there.

      ```c title=" " lineNumbers=1
      void lv_keyboard_set_textarea(lv_obj_t *kb, lv_obj_t *ta)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name | Type                                             | Description                                 |
      | ---- | ------------------------------------------------ | ------------------------------------------- |
      | `kb` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a keyboard object                |
      | `ta` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a text area object to write into |
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_set_mode" file="widgets/keyboard/lv_keyboard.h" line="83" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L83">
      lv_keyboard_set_mode [#lv_keyboard_set_mode]

      Set a new mode (e.g., text, number, special characters).

      ```c title=" " lineNumbers=1
      void lv_keyboard_set_mode(lv_obj_t *kb, lv_keyboard_mode_t mode)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                             | Description                                    |
      | ------ | ------------------------------------------------ | ---------------------------------------------- |
      | `kb`   | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a keyboard object                   |
      | `mode` | <ApiLink name="lv_keyboard_mode_t" />            | the desired mode (see 'lv\_keyboard\_mode\_t') |
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_set_popovers" file="widgets/keyboard/lv_keyboard.h" line="90" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L90">
      lv_keyboard_set_popovers [#lv_keyboard_set_popovers]

      Enable or disable popovers showing button titles on press.

      ```c title=" " lineNumbers=1
      void lv_keyboard_set_popovers(lv_obj_t *kb, bool en)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name | Type                                             | Description                               |
      | ---- | ------------------------------------------------ | ----------------------------------------- |
      | `kb` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a keyboard object              |
      | `en` | <ApiLink name="bool" />                          | true to enable popovers; false to disable |
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_set_map" file="widgets/keyboard/lv_keyboard.h" line="101" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L101">
      lv_keyboard_set_map [#lv_keyboard_set_map]

      Set a custom button map for the keyboard.

      ```c title=" " lineNumbers=1
      void lv_keyboard_set_map(lv_obj_t *kb, lv_keyboard_mode_t mode, const char *const map[], const lv_buttonmatrix_ctrl_t ctrl_map[])
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name       | Type                                                                             | Description                                                                                                                                               |
      | ---------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `kb`       | <ApiLink name="lv_obj_t" display="lv_obj_t *" />                                 | pointer to a keyboard object                                                                                                                              |
      | `mode`     | <ApiLink name="lv_keyboard_mode_t" />                                            | the mode to assign the new map to (see 'lv\_keyboard\_mode\_t')                                                                                           |
      | `map`      | `const char *const`                                                              | pointer to a string array describing the button map see '<ApiLink name="lv_buttonmatrix_set_map" display="lv_buttonmatrix_set_map()" />' for more details |
      | `ctrl_map` | <ApiLink name="lv_buttonmatrix_ctrl_t" display="const lv_buttonmatrix_ctrl_t" /> | pointer to the control map. See '<ApiLink name="lv_buttonmatrix_set_ctrl_map" display="lv_buttonmatrix_set_ctrl_map()" />'                                |
    </ApiMember>
  </ApiTab>

  <ApiTab value="Getters (6)">
    <ApiMember kind="function" name="lv_keyboard_get_textarea" file="widgets/keyboard/lv_keyboard.h" line="113" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L113">
      lv_keyboard_get_textarea [#lv_keyboard_get_textarea]

      Get the text area currently assigned to the keyboard.

      ```c title=" " lineNumbers=1
      lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t *kb)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name | Type                                                   | Description                  |
      | ---- | ------------------------------------------------------ | ---------------------------- |
      | `kb` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a keyboard object |

      **Returns:** <ApiLink name="lv_obj_t" display="lv_obj_t *" /> — pointer to the assigned text area object
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_get_mode" file="widgets/keyboard/lv_keyboard.h" line="120" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L120">
      lv_keyboard_get_mode [#lv_keyboard_get_mode]

      Get the current mode of the keyboard.

      ```c title=" " lineNumbers=1
      lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t *kb)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name | Type                                                   | Description                  |
      | ---- | ------------------------------------------------------ | ---------------------------- |
      | `kb` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a keyboard object |

      **Returns:** <ApiLink name="lv_keyboard_mode_t" /> — the current mode (see 'lv\_keyboard\_mode\_t')
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_get_popovers" file="widgets/keyboard/lv_keyboard.h" line="127" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L127">
      lv_keyboard_get_popovers [#lv_keyboard_get_popovers]

      Check whether popovers are enabled on the keyboard.

      ```c title=" " lineNumbers=1
      bool lv_keyboard_get_popovers(const lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                   | Description                  |
      | ----- | ------------------------------------------------------ | ---------------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a keyboard object |

      **Returns:** <ApiLink name="bool" /> — true if popovers are enabled; false otherwise
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_get_map_array" file="widgets/keyboard/lv_keyboard.h" line="134" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L134">
      lv_keyboard_get_map_array [#lv_keyboard_get_map_array]

      Get the current button map of the keyboard.

      ```c title=" " lineNumbers=1
      const char *const  * lv_keyboard_get_map_array(const lv_obj_t *kb)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name | Type                                                   | Description                  |
      | ---- | ------------------------------------------------------ | ---------------------------- |
      | `kb` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a keyboard object |

      **Returns:** `const char *const *` — pointer to the map array
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_get_selected_button" file="widgets/keyboard/lv_keyboard.h" line="143" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L143">
      lv_keyboard_get_selected_button [#lv_keyboard_get_selected_button]

      Get the index of the last selected button (pressed, released, focused, etc.). Useful in the `event_cb` to retrieve button text or properties.

      ```c title=" " lineNumbers=1
      uint32_t lv_keyboard_get_selected_button(const lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                   | Description                  |
      | ----- | ------------------------------------------------------ | ---------------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a keyboard object |

      **Returns:** <ApiLink name="uint32_t" /> — index of the last interacted button returns LV\_BUTTONMATRIX\_BUTTON\_NONE if not set
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_get_button_text" file="widgets/keyboard/lv_keyboard.h" line="151" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L151">
      lv_keyboard_get_button_text [#lv_keyboard_get_button_text]

      Get the text of a button by index.

      ```c title=" " lineNumbers=1
      const char * lv_keyboard_get_button_text(const lv_obj_t *obj, uint32_t btn_id)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                                                   | Description                                        |
      | -------- | ------------------------------------------------------ | -------------------------------------------------- |
      | `obj`    | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a keyboard object                       |
      | `btn_id` | <ApiLink name="uint32_t" />                            | index of the button (excluding newline characters) |

      **Returns:** `const char *` — pointer to the text of the button
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (2)">
    <ApiMember kind="function" name="lv_keyboard_create" file="widgets/keyboard/lv_keyboard.h" line="65" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L65">
      lv_keyboard_create [#lv_keyboard_create]

      Create a Keyboard object

      ```c title=" " lineNumbers=1
      lv_obj_t * lv_keyboard_create(lv_obj_t *parent)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                                             | Description                                                     |
      | -------- | ------------------------------------------------ | --------------------------------------------------------------- |
      | `parent` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object, it will be the parent of the new keyboard |

      **Returns:** <ApiLink name="lv_obj_t" display="lv_obj_t *" /> — pointer to the created keyboard object
    </ApiMember>

    <ApiMember kind="function" name="lv_keyboard_def_event_cb" file="widgets/keyboard/lv_keyboard.h" line="163" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L163">
      lv_keyboard_def_event_cb [#lv_keyboard_def_event_cb]

      Default keyboard event callback to handle button presses. Adds characters to the text area and switches map if needed. If a custom `event_cb` is used, this function can be called within it.

      ```c title=" " lineNumbers=1
      void lv_keyboard_def_event_cb(lv_event_t *e)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name | Type                                                 | Description          |
      | ---- | ---------------------------------------------------- | -------------------- |
      | `e`  | <ApiLink name="lv_event_t" display="lv_event_t *" /> | the triggering event |
    </ApiMember>
  </ApiTab>
</ApiTabs>

Enums [#enums]

<ApiMember kind="enum" name="lv_keyboard_mode_t" file="widgets/keyboard/lv_keyboard.h" line="30" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L30">
  lv_keyboard_mode_t [#lv_keyboard_mode_t]

  Current keyboard mode.

  | Name                           |
  | ------------------------------ |
  | `LV_KEYBOARD_MODE_TEXT_LOWER`  |
  | `LV_KEYBOARD_MODE_TEXT_UPPER`  |
  | `LV_KEYBOARD_MODE_SPECIAL`     |
  | `LV_KEYBOARD_MODE_NUMBER`      |
  | `LV_KEYBOARD_MODE_USER_1`      |
  | `LV_KEYBOARD_MODE_USER_2`      |
  | `LV_KEYBOARD_MODE_USER_3`      |
  | `LV_KEYBOARD_MODE_USER_4`      |
  | `LV_KEYBOARD_MODE_TEXT_ARABIC` |
</ApiMember>

<TypeUsedBy name="lv_keyboard_mode_t" count="2">
  * `lv_keyboard_set_mode` — param `mode`
  * `lv_keyboard_set_map` — param `mode`
</TypeUsedBy>

<ApiMember kind="enum" name="_lv_property_keyboard_id_t" file="widgets/keyboard/lv_keyboard.h" line="45" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L45">
  \_lv_property_keyboard_id_t [#_lv_property_keyboard_id_t]

  | Name                                   | Value                                                             |
  | -------------------------------------- | ----------------------------------------------------------------- |
  | `LV_PROPERTY_KEYBOARD_TEXTAREA`        | `(LV_PROPERTY_KEYBOARD_START + ((int) 0 )) \| ((  8   ) <<  28 )` |
  | `LV_PROPERTY_KEYBOARD_MODE`            | `(LV_PROPERTY_KEYBOARD_START + ((int) 1 )) \| ((  1   ) <<  28 )` |
  | `LV_PROPERTY_KEYBOARD_POPOVERS`        | `(LV_PROPERTY_KEYBOARD_START + ((int) 2 )) \| ((  1   ) <<  28 )` |
  | `LV_PROPERTY_KEYBOARD_SELECTED_BUTTON` | `(LV_PROPERTY_KEYBOARD_START + ((int) 3 )) \| ((  1   ) <<  28 )` |
  | `LV_PROPERTY_KEYBOARD_END`             |                                                                   |
</ApiMember>

Macros [#macros]

<ApiMember kind="macro" name="LV_KEYBOARD_CTRL_BUTTON_FLAGS" file="widgets/keyboard/lv_keyboard.h" line="23" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L23">
  LV_KEYBOARD_CTRL_BUTTON_FLAGS [#lv_keyboard_ctrl_button_flags]

  ```c title=" " lineNumbers=1
  #define LV_KEYBOARD_CTRL_BUTTON_FLAGS (LV_BUTTONMATRIX_CTRL_NO_REPEAT | LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_CHECKED)
  ```
</ApiMember>

Variables [#variables]

<ApiMember kind="variable" name="lv_keyboard_class" file="widgets/keyboard/lv_keyboard.h" line="54" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/keyboard/lv_keyboard.h#L54">
  lv_keyboard_class [#lv_keyboard_class]

  ```c title=" " lineNumbers=1
  const lv_obj_class_t lv_keyboard_class
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_buttonmatrix.h&#x22;]" includedBy="[&#x22;lv_keyboard_private.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_array.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_display.h&#x22;, &#x22;lv_draw.h&#x22;, &#x22;lv_draw_arc.h&#x22;, &#x22;lv_draw_blur.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_draw_image.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_draw_line.h&#x22;, &#x22;lv_draw_rect.h&#x22;, &#x22;lv_draw_triangle.h&#x22;, &#x22;lv_event.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_fs.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_image_decoder.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_indev.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_matrix.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_obj.h&#x22;, &#x22;lv_obj_class.h&#x22;, &#x22;lv_obj_draw.h&#x22;, &#x22;lv_obj_event.h&#x22;, &#x22;lv_obj_pos.h&#x22;, &#x22;lv_obj_property.h&#x22;, &#x22;lv_obj_property_names.h&#x22;, &#x22;lv_obj_scroll.h&#x22;, &#x22;lv_obj_style.h&#x22;, &#x22;lv_obj_style_gen.h&#x22;, &#x22;lv_obj_tree.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_profiler.h&#x22;, &#x22;lv_profiler_builtin.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_style_properties.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
