⌨️ Keyboard
The Keyboard widget is a specialized input interface that allows users to enter text and numeric data. It is essentially an optimized Button Matrix with built-in logic for handling character mapping, shift states, and cursor control.
⚙️ Properties (Props)
The Keyboard configuration is defined by the KeyboardWidget interface. Its primary function is to act as an input provider for another widget.
| Property | Type | Description |
|---|---|---|
| Target Text | widgetId | The ID of the Text Input or Label widget where the characters will be sent. |
| Mode | Dropdown | Switch between layouts: Text, Number, or Special Characters. |
| Pop-up | boolean | If enabled, the keyboard only appears when the target widget is focused. |
🛠 Target Integration
The Keyboard does not store text itself; it manipulates a Target.
- Binding: In the Inspector Panel, use the
Targetpicker to select a Text Area. - Interaction: When a user clicks a key, the Keyboard sends the character to the target's cursor position.
- Completion: The "Enter" or "Check" key on the keyboard typically triggers a
READYevent, allowing you to validate the input.
🎨 Visual Layouts
Artok supports several built-in maps that change the keyboard's appearance instantly:
- QWERTY: Full alphanumeric layout for names and descriptions.
- Number Pad: Large keys optimized for PIN entry or setting numeric values (like temperature).
- Hexadecimal: Optimized for engineering tools requiring hex input (0-F).
⚡ Runtime API (Lua)
You can use the Logic and Events system to control the keyboard's visibility and behavior.
-- Change the target widget at runtime
kb_main:set_textarea(input_username)
-- Force the keyboard into numeric mode for a specific field
kb_main:set_mode("number")
-- Manually show or hide the keyboard
kb_main:set_hidden(false)
Instead of placing a keyboard on every screen, create one global keyboard on a Top Layer and use Lua to update its targetText whenever a user clicks an input field.
🚀 Next Steps
- Text Area — The most common target for keyboard input.
- Button Matrix — Use this if you need a completely custom grid of keys (like a calculator).
- Logic and Events — Learn how to capture the
READYevent to save user input.