Skip to content

Input

The Input class provides a set of static methods for handling user input and controller input operations.

静态变量

Input.mouseDeltaPosition : Vector2
(Read Only) The distance the mouse or touch screen has moved since the last frame.
Input.mousePosition : Vector2
(Read Only) The position of the mouse pointer on the screen.
Input.mouseScrollDelta : Vector2
(Read Only) The scroll value of the mouse wheel relative to the previous frame.
Input.inputString : string
(Read Only) The most recent input text string.
Input.touchCount : number
(Read Only) The number of touches.

静态方法

Input.GetKey ( key : KeyCode ) : boolean
Checks if the specified key is currently being pressed in the current frame.
Input.GetMouseButton ( button : MouseButton ) : boolean
Checks if the specified mouse button is in the pressed state.
Input.GetKeyDown ( key : KeyCode ) : boolean
Detects whether the specified key is pressed in the current frame's key down event.
Input.GetMouseButtonDown ( button : MouseButton ) : boolean
Checks if the specified mouse button is pressed in the current frame's button down event.
Input.GetKeyUp ( key : KeyCode ) : boolean
Detects whether the specified key is released in the current frame's key release event.
Input.GetMouseButtonUp ( button : MouseButton ) : boolean
Checks if the specified mouse button is released in the current frame's release event.
Input.GetTouch ( index : number ) : Touch
Get the status and position information of the specified touch point on the touch screen.
Input.GetTouchByID ( id : number ) : Touch
Get the status and position information of the specified ID on the touch screen.