OnTextInput
A character was typed while the script has the keyboard.
For a text field of the script’s own - a name, a password: the character as the player’s keyboard layout makes it (a
German keyboard’s Z is a Z here, while OnKey names the key at that place y), with Shift and the layout’s accents
applied, as UTF-8. It comes only while the script holds the keyboard (SetKeyboardCapture), next to the key’s own
OnKey; Enter, Backspace, Esc and Tab come as keys alone.
Syntax
Section titled “Syntax”function OnTextInput(text) -- ...end| Parameter | Type | |
|---|---|---|
text |
string | the character typed (UTF-8) |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”local chars = {} -- one entry per character: Backspace takes a whole one, whatever its bytesfunction OnTextInput(text) if #chars < 24 then chars[#chars + 1] = text SetUiText("field", table.concat(chars)) endendfunction OnKey(key, pressed) if pressed and key == "backspace" then table.remove(chars) SetUiText("field", table.concat(chars)) endendSee also
Section titled “See also”SetKeyboardCapture · OnKey · the The game’s UI for a script group of the index
