Input Service
Input is a service that manages keyboard and mouse input.
It provides signals for key/button presses and releases, as well as helper functions to query input state and mouse position.
Input Service Service Singleton
Signals
Input.InputBegan Signal
- Fires when a keyboard key or mouse button is pressed.
Parameters:
- InputData table— Input information
- InputType string— Type of input
Keyboard|Mouse - InputKey string?— Released key (if keyboard)
- InputCode number?— Key code (if keyboard)
- InputButton string?— Released button (if mouse)
- InputType
Input.InputEnded Signal
- Fires when a keyboard key or mouse button is released.
Parameters:
- InputData table— Input information
- InputType string— Type of input
Keyboard|Mouse - InputKey string?— Released key (if keyboard)
- InputCode number?— Key code (if keyboard)
- InputButton string?— Released button (if mouse)
- InputType
Functions
Input.IsKeyDown() Function
Input.IsKeyDown(key)
- Checks if a key is currently pressed.
Parameters:
- key string?number?— Key to check
Returns:
booleanboolean—trueif the key is pressed
Input.IsKeyUp() Function
Input.IsKeyUp(key)
Checks if a key is currently released.
Parameters:
- key string?number?— Key to check
Returns:
booleanboolean—trueif the key is released
Input.MousePosition() Function
Input.MousePosition(window)
- Returns the current mouse position.
Parameters:
- window Window?— Optional window to get relative position
Returns:
Vector2Vector2— Mouse position
Internal Functions
Input:Update() Internal
- Internal update function used by Weo to track input state each frame.
Parameters:
- dt number
- Delta time for the frame
Do not call this manually.
This method is automatically invoked byUpdateServiceand is not intended for direct use in user code.
Example
--- Kill app with ESCAPE
Input.InputBegan:Connect(function (input)
if input.InputType == Enum.InputType.Keyboard then
if input.InputCode == Enum.VirtualKeyCodes.Key.ESCAPE then
UpdateService:Kill()
end
end
end)
--- Check if ESCAPE is pressed
print(Input.IsKeyDown(Enum.VirtualKeyCodes.Key.ESCAPE))