The Keyboard is used in programming to take text input. It is used by clicking on it or connecting it to a VehicleSeat, typing text and pressing enter. It is to note the newline caused by pressing enter to input is included in the text.
In-game Description[edit | hide all | hide | edit source]
"Similar to a button, except is programmable to take more than one key input. Can be attached to a vehicle seat or clicked by a player."
Configuration[edit | hide | edit source]
- Cannot be configured.
Programming Example[edit | hide | edit source]
This program takes keyboard input and prints it to a screen
local Screen = GetPartFromPort(1, 'Screen') -- gets a Screen
local Keyboard = GetPartFromPort(2, "Keyboard") -- gets a Keyboard
Screen:ClearElements() -- Clears screen
local TextLabel = Screen:CreateElement('TextLabel', {
AnchorPoint = Vector2.new(0.5, 0.5);
Position = UDim2.fromScale(0.5, 0.5);
Size = UDim2.fromScale(1, 1);
Text = ' ';
TextSize = 20;
TextScaled = false;
}) -- Creates a container for text
local function WriteScreen(text)
text = text:sub(1, -2) --removes the newline from pressing enter to confirm keyboard input
TextLabel:ChangeProperties({ -- change the text
Text = text;
})
end -- function to edit text label
Keyboard:Connect("TextInputted", WriteScreen)
-- when text is inputted to the keyboard it will run the WriteScreen function