Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Input

Inherits: Object

A singleton for handling inputs.

Description

The Input singleton handles key presses, mouse buttons and movement, gamepads, and input actions. Actions and their events can be set in the Input Map tab in Project > Project Settings, or with the InputMap class.

Note: Input's methods reflect the global input state and are not affected by Control.accept_event or Viewport.set_input_as_handled, as those methods only deal with the way input is propagated in the SceneTree.

Tutorials

Properties

bool

emulate_mouse_from_touch

bool

emulate_touch_from_mouse

MouseMode

mouse_mode

bool

use_accumulated_input

Methods

void

action_press(action: StringName, strength: float = 1.0)

void

action_release(action: StringName)

void

add_joy_mapping(mapping: String, update_existing: bool = false)

void

flush_buffered_events()

Vector3

get_accelerometer() const

float

get_action_raw_strength(action: StringName, exact_match: bool = false) const

float

get_action_strength(action: StringName, exact_match: bool = false) const

float

get_axis(negative_action: StringName, positive_action: StringName) const

Array[int]

get_connected_joypads()

CursorShape

get_current_cursor_shape() const

Vector3

get_gravity() const

Vector3

get_gyroscope() const

float

get_joy_axis(device: int, axis: JoyAxis) const

String

get_joy_guid(device: int) const

Dictionary

get_joy_info(device: int) const

String

get_joy_name(device: int)

float

get_joy_vibration_duration(device: int)

Vector2

get_joy_vibration_strength(device: int)

Vector2

get_last_mouse_screen_velocity()

Vector2

get_last_mouse_velocity()

Vector3

get_magnetometer() const

BitField[MouseButtonMask]

get_mouse_button_mask() const

Vector2

get_vector(negative_x: StringName, positive_x: StringName, negative_y: StringName, positive_y: StringName, deadzone: float = -1.0) const

bool

is_action_just_pressed(action: StringName, exact_match: bool = false) const

bool

is_action_just_released(action: StringName, exact_match: bool = false) const

bool

is_action_pressed(action: StringName, exact_match: bool = false) const

bool

is_anything_pressed() const

bool</