A Singleton that deals with inputs.
    public static class Input

A Singleton that deals with inputs. This includes key presses, mouse buttons and movement, joypads, and input actions. Actions and their events can be set in the Project Settings / Input Map tab. Or be set with InputMap.

Inheritance Chain

Static Methods

    public static void ActionPress(string action)

This will simulate pressing the specified action.

    public static void ActionRelease(string action)

If the specified action is already pressed, this will release it.

    public static void AddJoyMapping(string mapping, bool updateExisting = false)

Add a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.

    public static Vector3 GetAccelerometer()

If the device has an accelerometer, this will return the movement.

    public static object[] GetConnectedJoypads()

Returns an Array containing the device IDs of all currently connected joypads.

    public static Vector3 GetGravity()

    public static Vector3 GetGyroscope()

If the device has a gyroscope, this will return the rate of rotation in rad/s around a device’s x, y, and z axis.

    public static float GetJoyAxis(int device, int axis)

Returns the current value of the joypad axis at given index (see JOY_* constants in [@GlobalScope])

    public static int GetJoyAxisIndexFromString(string axis)

    public static string GetJoyAxisString(int axisIndex)

    public static int GetJoyButtonIndexFromString(string button)

    public static string GetJoyButtonString(int buttonIndex)

    public static string GetJoyGuid(int device)

Returns a SDL2 compatible device guid on platforms that use gamepad remapping. Returns “Default Gamepad” otherwise.

    public static string GetJoyName(int device)

Returns the name of the joypad at the specified device index

    public static float GetJoyVibrationDuration(int device)

Returns the duration of the current vibration effect in seconds.

    public static Vector2 GetJoyVibrationStrength(int device)

Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.

    public static Vector2 GetLastMouseSpeed()

Returns the mouse speed for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion.

    public static Vector3 GetMagnetometer()

If the device has a magnetometer, this will return the magnetic field strength in micro-Tesla for all axes.

    public static int GetMouseButtonMask()

Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time the bits are added together.

    public static MouseMode GetMouseMode()

Return the mouse mode. See the constants for more information.

    public static bool IsActionJustPressed(string action)

Returns true when you start pressing the action event.

    public static bool IsActionJustReleased(string action)

Returns true when you stop pressing the action event.

    public static bool IsActionPressed(string action)

Returns true if you are pressing the action event.

    public static bool IsJoyButtonPressed(int device, int button)

Returns true if you are pressing the joypad button. (see JOY_* constants in [@GlobalScope])

    public static bool IsJoyKnown(int device)

Returns true if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in the JOY_* constants (see [@GlobalScope]). Unknown joypads are not expected to match these constants, but you can still retrieve events from them.

    public static bool IsKeyPressed(int scancode)

Returns true if you are pressing the key. You can pass KEY_*, which are pre-defined constants listed in [@GlobalScope].

    public static bool IsMouseButtonPressed(int button)

Returns true if you are pressing the mouse button. You can pass button, which are pre-defined constants listed in [@GlobalScope].

    public static void JoyConnectionChanged(int device, bool connected, string name, string guid)

    public static void ParseInputEvent(InputEvent @event)

    public static void RemoveJoyMapping(string guid)

Removes all mappings from the internal db that match the given uid.

    public static void SetCustomMouseCursor(Resource image, CursorShape shape = CursorShape.Arrow, Vector2? hotspot = default(Vector2?))

Set a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. See enum CURSOR_* for the list of shapes.

    public static void SetMouseMode(MouseMode mode)

Set the mouse mode. See the constants for more information.

    public static void StartJoyVibration(int device, float weakMagnitude, float strongMagnitude, float duration = 0f)

Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. weak_magnitude is the strength of the weak motor (between 0 and 1) and strong_magnitude is the strength of the strong motor (between 0 and 1). duration is the duration of the effect in seconds (a duration of 0 will try to play the vibration indefinitely).

Note that not every hardware is compatible with long effect durations, it is recommended to restart an effect if in need to play it for more than a few seconds.

    public static void StopJoyVibration(int device)

Stops the vibration of the joypad.

    public static void WarpMousePosition(Vector2 to)

Sets the mouse position to the specified vector.


    "joy_connection_changed" (int index, bool connected)

Emitted when a joypad device has been connected or disconnected

Inner Types


Name Value Description
Arrow 0  
Ibeam 1  
PointingHand 2  
Cross 3  
Wait 4  
Busy 5  
Drag 6  
CanDrop 7  
Forbidden 8  
Vsize 9  
Hsize 10  
Bdiagsize 11  
Fdiagsize 12  
Move 13  
Vsplit 14  
Hsplit 15  
Help 16  


Name Value Description
Visible 0 Makes the mouse cursor visible if it is hidden.
Hidden 1 Makes the mouse cursor hidden if it is visible.
Captured 2 Captures the mouse. The mouse will be hidden and unable to leave the game window. But it will still register movement and mouse button presses.
Confined 3