Input¶
Static Class
This object is a static class. It can be accessed by using it's name as a keyword like this Input
.
Additionally, it cannot be created in the creator menu or with Instance.New()
Input is a class used for retrieving user input data, such as the mouse and keyboard.
Events¶
KeyDown¶
Parameters: 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¶
Parameters: 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¶
Undocumented Methods
This section is a work in progress! The methods GetMouseWorldPoint
, GetMouseWorldPosition
, ScreenPointToRay
, and ViewportPointToRay
are not written yet. Want to contribute? Go to the GitHub and open a pull request here!
ScreenToViewportPoint → Vector3¶
Parameters: screenPosition [ Vector3 ]
Transforms screenPosition
parameter from screen space into viewport space.
ScreenToWorldPoint → Vector3¶
Parameters: screenPosition [ Vector3 ]
Transforms screenPosition
from screen space into world space.
World space coordinates can still be calculated even when provided as an off-screen coordinate.
ViewportToScreenPoint → Vector3¶
Parameters: viewportPosition [ Vector3 ]
Transforms viewportPosition
from viewport space into screen space.
ViewportToWorldPoint → Vector3¶
Parameters: viewportPosition [ Vector3 ]
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 → Vector3¶
Parameters: worldPosition [ Vector3 ]
Transforms worldPosition
from world space into screen space.
WorldToViewportPoint → Vector3¶
Parameters: worldPosition [ Vector3 ]
Transforms worldPosition
from world space into viewport space.
Properties¶
MousePosition : Vector2¶
Returns the current mouse position.
CursorLocked : boolean
¶
to-do
Example
Input.CursorLocked = true
CursorVisible : boolean
¶
to do
Example
Input.CursorVisible = true