Input
Input is a class used for retrieving user input data, such as the mouse and keyboard.
Summary
Properties
AnyKey:boolAnyKeyDown:boolIsInputFocused:boolRead OnlyMousePosition:Vector2CursorLocked:boolCursorVisible:boolScreenWidth:floatRead OnlyScreenHeight:floatRead Only
Methods
GetAxis:floatGetAxisRaw:floatGetButton:boolGetButtonDown:boolGetButtonUp:boolGetKey:boolGetKeyDown:boolGetKeyUp:boolGetMouseButton:boolGetMouseButtonDown:boolGetMouseButtonUp:boolGetMouseWorldPosition:Vector3:voidScreenPointToRay:RayResultViewportPointToRay:RayResultScreenToViewportPoint:Vector3ScreenToWorldPoint:Vector3ViewportToScreenPoint:Vector3ViewportToWorldPoint:Vector3WorldToScreenPoint:Vector3WorldToViewportPoint:Vector3
Events
Properties
AnyKey
Input.AnyKey: bool
Returns true if any key is being pressed.
AnyKeyDown
Input.AnyKeyDown: bool
Returns true if any new key presses happened during the current frame. Held down key presses from previous frames do not count.
IsInputFocused
Input.IsInputFocused: bool
Determines whether or not the local player is currently focused on an input.
MousePosition
Input.MousePosition: Vector2
Returns the current mouse position.
CursorLocked
Input.CursorLocked: bool
Determines whether or not the cursor is locked.
Example
Input.CursorLocked = true
CursorVisible
Input.CursorVisible: bool
Determines whether or not the cursor is visible.
Example
Input.CursorVisible = true
ScreenWidth
Input.ScreenWidth: float
Returns the current screen's width.
ScreenHeight
Input.ScreenHeight: float
Returns the current screen's height.
Methods
GetAxis
Input:GetAxis(axisName: string): float
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
axisName | string | - |
Returns the value of the specified axis.
GetAxisRaw
Input:GetAxisRaw(axisName: string): float
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
axisName | string | - |
Returns the value of the specified axis without smoothing filtering.
GetButton
Input:GetButton(buttonName: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
buttonName | string | - |
Returns true if the specified button is being held down.
GetButtonDown
Input:GetButtonDown(buttonName: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
buttonName | string | - |
Returns true during the frame in which the specified button was pressed.
GetButtonUp
Input:GetButtonUp(buttonName: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
buttonName | string | - |
Returns true during the frame in which the specified button was released.
GetKey
Input:GetKey(keyName: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
keyName | string | - |
Returns true if the specified key is being held down.
GetKeyDown
Input:GetKeyDown(keyName: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
keyName | string | - |
Returns true during the frame in which the specified key was pressed.
GetKeyUp
Input:GetKeyUp(keyName: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
keyName | string | - |
Returns true during the frame in which the specified key was released.
GetMouseButton
Input:GetMouseButton(mouseButton: int): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
mouseButton | int | - |
Returns true if the specified mouse button is being held down.
GetMouseButtonDown
Input:GetMouseButtonDown(mouseButton: int): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
mouseButton | int | - |
Returns true during the frame in which the specified mouse button was pressed.
GetMouseButtonUp
Input:GetMouseButtonUp(mouseButton: int): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
mouseButton | int | - |
Returns true during the frame in which the specified mouse button was released.
GetMouseWorldPosition:Vector3
Input:GetMouseWorldPosition:Vector3()
Returns the 3D world-space position corresponding to the current mouse cursor location.
ScreenPointToRay
Input:ScreenPointToRay(position: Vector3, List ignoreList = null: any): RayResult
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
position | Vector3 | - | |
List ignoreList = null | any | - |
Cast a ray from the camera at screen point into the game world
ViewportPointToRay
Input:ViewportPointToRay(position: Vector3, List ignoreList = null: any): RayResult
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
position | Vector3 | - | |
List ignoreList = null | any | - |
Cast a ray from the camera at the specified ViewportPoint (Vector3 with components with values in range of 0 - 1 describing how far a point is to to right and to the top of the screen) into the game world
ScreenToViewportPoint
Input:ScreenToViewportPoint(screenPosition: Vector3): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
screenPosition | Vector3 | - |
Transforms screenPosition parameter from screen space into viewport space.
ScreenToWorldPoint
Input:ScreenToWorldPoint(screenPosition: Vector2): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
screenPosition | Vector2 | - |
Transforms screenPosition from screen space into world space.
ViewportToScreenPoint
Input:ViewportToScreenPoint(viewportPosition: Vector2): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
viewportPosition | Vector2 | - |
Transforms viewportPosition from viewport space into screen space.
ViewportToWorldPoint
Input:ViewportToWorldPoint(viewportPosition: Vector2): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
viewportPosition | Vector2 | - |
Transforms viewportPosition from viewport space into world space.
WorldToScreenPoint
Input:WorldToScreenPoint(worldPosition: Vector3): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
worldPosition | Vector3 | - |
Transforms worldPosition from world space into screen space.
WorldToViewportPoint
Input:WorldToViewportPoint(worldPosition: Vector3): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
worldPosition | Vector3 | - |
Transforms worldPosition from world space into viewport space.
Properties
Events
KeyDown
Input.KeyDown(key: string)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Fires when a key is pressed.
Example
Input.KeyDown:Connect(function (key)
print(key .. " was pressed!")
if key == "P" then
print("The 'P' key was pressed!")
end
end)
KeyUp
Input.KeyUp(key: string)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Fires when a key is released.
Input.KeyUp:Connect(function (key)
print(key .. " was pressed!")
if key == "P" then
print("The 'P' key was pressed!")
end
end)
Methods
This section is a work in progress! The method GetMouseWorldPoint is not written yet. Want to contribute? Go to the GitHub and open a pull request here!