Skip to main content

Input

Input is a class used for retrieving user input data, such as the mouse and keyboard.


Summary

Properties

Methods

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:

ParameterTypeDefaultDescription
axisNamestring-

Returns the value of the specified axis.


GetAxisRaw

Input:GetAxisRaw(axisName: string): float

Parameters:

ParameterTypeDefaultDescription
axisNamestring-

Returns the value of the specified axis without smoothing filtering.


GetButton

Input:GetButton(buttonName: string): bool

Parameters:

ParameterTypeDefaultDescription
buttonNamestring-

Returns true if the specified button is being held down.


GetButtonDown

Input:GetButtonDown(buttonName: string): bool

Parameters:

ParameterTypeDefaultDescription
buttonNamestring-

Returns true during the frame in which the specified button was pressed.


GetButtonUp

Input:GetButtonUp(buttonName: string): bool

Parameters:

ParameterTypeDefaultDescription
buttonNamestring-

Returns true during the frame in which the specified button was released.


GetKey

Input:GetKey(keyName: string): bool

Parameters:

ParameterTypeDefaultDescription
keyNamestring-

Returns true if the specified key is being held down.


GetKeyDown

Input:GetKeyDown(keyName: string): bool

Parameters:

ParameterTypeDefaultDescription
keyNamestring-

Returns true during the frame in which the specified key was pressed.


GetKeyUp

Input:GetKeyUp(keyName: string): bool

Parameters:

ParameterTypeDefaultDescription
keyNamestring-

Returns true during the frame in which the specified key was released.


GetMouseButton

Input:GetMouseButton(mouseButton: int): bool

Parameters:

ParameterTypeDefaultDescription
mouseButtonint-

Returns true if the specified mouse button is being held down.


GetMouseButtonDown

Input:GetMouseButtonDown(mouseButton: int): bool

Parameters:

ParameterTypeDefaultDescription
mouseButtonint-

Returns true during the frame in which the specified mouse button was pressed.


GetMouseButtonUp

Input:GetMouseButtonUp(mouseButton: int): bool

Parameters:

ParameterTypeDefaultDescription
mouseButtonint-

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:

ParameterTypeDefaultDescription
positionVector3-
List ignoreList = nullany-

Cast a ray from the camera at screen point into the game world


ViewportPointToRay

Input:ViewportPointToRay(position: Vector3, List ignoreList = null: any): RayResult

Parameters:

ParameterTypeDefaultDescription
positionVector3-
List ignoreList = nullany-

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:

ParameterTypeDefaultDescription
screenPositionVector3-

Transforms screenPosition parameter from screen space into viewport space.


ScreenToWorldPoint

Input:ScreenToWorldPoint(screenPosition: Vector2): Vector3

Parameters:

ParameterTypeDefaultDescription
screenPositionVector2-

Transforms screenPosition from screen space into world space.

World space coordinates can still be calculated even when provided as an off-screen coordinate.

ViewportToScreenPoint

Input:ViewportToScreenPoint(viewportPosition: Vector2): Vector3

Parameters:

ParameterTypeDefaultDescription
viewportPositionVector2-

Transforms viewportPosition from viewport space into screen space.


ViewportToWorldPoint

Input:ViewportToWorldPoint(viewportPosition: Vector2): Vector3

Parameters:

ParameterTypeDefaultDescription
viewportPositionVector2-

Transforms viewportPosition from viewport space into world space.

ViewportToWorldPoint transforms an x-y screen position into a x-y-z position in 3D space.

WorldToScreenPoint

Input:WorldToScreenPoint(worldPosition: Vector3): Vector3

Parameters:

ParameterTypeDefaultDescription
worldPositionVector3-

Transforms worldPosition from world space into screen space.


WorldToViewportPoint

Input:WorldToViewportPoint(worldPosition: Vector3): Vector3

Parameters:

ParameterTypeDefaultDescription
worldPositionVector3-

Transforms worldPosition from world space into viewport space.

Properties


Events

KeyDown

Input.KeyDown(key: string)

Parameters:

ParameterTypeDefaultDescription
keystring-

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:

ParameterTypeDefaultDescription
keystring-

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

Undocumented 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!