Keyboard

Report on GitHub

Per-button colors via draw task hook

Recolor each keyboard key and swap the OK symbol for a star image.

A centered lv_keyboard has LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS set and a LV_EVENT_DRAW_TASK_ADDED callback attached. For every LV_PART_ITEMS draw task the handler picks a palette entry from base_dsc->id1, darkens it while the button is in LV_STATE_PRESSED, and lightens the label text. When the task is drawing LV_SYMBOL_OK the label is hidden and img_star is drawn in its place.

AZERTY layout as USER_1 mode

Register a custom AZERTY button map on the keyboard.

A kb_map and matching lv_buttonmatrix_ctrl_t control array describe an AZERTY layout with LV_SYMBOL_BACKSPACE, LV_SYMBOL_NEW_LINE, LV_SYMBOL_CLOSE, and LV_SYMBOL_OK. lv_keyboard_set_map installs the layout under LV_KEYBOARD_MODE_USER_1 and lv_keyboard_set_mode activates it. A focused textarea above the keyboard receives the typed characters.

Keyboard modes

Switch between text and number layouts via the mode attribute.

mode selects the keymap LVGL shows. text_lower/text_upper give the letter layouts with case shift keys; special swaps in punctuation; number shows the calculator-style numeric pad. The mode persists until changed — pressing the in-layout ABC/abc/1# keys switches the keymap at runtime, while this attribute pins the initial layout.

Keyboard pop-overs

Enlarged preview balloons appear above the pressed key while held.

With popovers="true" LVGL renders a larger preview of the active key above the keyboard while it's pressed, the same way mobile OS keyboards do. The preview only renders for keys that produce a symbol (so space and modifier keys stay quiet). Pop-overs in the top row can extend outside the keyboard's bounds — leave free space above it (here the textarea provides that headroom).

Keyboard with text area

Pair a keyboard with a textarea so typed keys land in the field.

The keyboard and the textarea sit on the same screen; LVGL's default focus group routes key presses to whichever input widget currently holds focus (here the textarea is the only one). In runtime code you'd usually call lv_keyboard_set_textarea(kb, ta) to pin the link explicitly, but for a single textarea on a screen the default group is sufficient.

Last updated on

On this page