! Type text via key events (key.send_text)
The hardware keyboard behavior described on this page is available in versions after 20260805
Declaration
key.send_text(text [, per_key_delay_ms, shift_delay_ms])
Parameters
- text
String. Text to type. Only English letters, digits, spaces, half-width symbols, and escape sequences
"\b","\r", and"\t"are supported. - per_key_delay_ms Integer. Delay between key events in milliseconds. Default: no delay, so input is sent as fast as the device allows.
- shift_delay_ms
Integer. Delay for Shift in milliseconds. Uppercase letters and some symbols require holding Shift; for example,
@isShift + 2.
Description
This function is useful when
sys.input_textis ineffective; it forces text input by simulating key events.
- After a global hardware keyboard is connected, text is entered through that object. Without one, the previous behavior is preserved.
- The hardware keyboard generates key and Shift combinations from the current Lua US keyboard mapping. The resulting characters are still affected by the target system's keyboard layout.
- When entered through the hardware keyboard, keys that were already held before the call are preserved. Failed input is not retried through the previous input method.
Examples
key.send_text("AbC12#") -- type as fast as possible
--
key.send_text("AbC12#", 300) -- 300 ms delay between each key