Skip to main content

InputEvent

Inherits: Resource < RefCounted < Object

Description

Abstract base class for input events. All types of input events inherit from this class.

Properties

device
int
default:"0"
The event’s device ID.

Methods

is_action_pressed

bool is_action_pressed(action: StringName, allow_echo: bool = false, exact_match: bool = false)
Returns true if the given action matches this event and is being pressed.

is_action_released

bool is_action_released(action: StringName, exact_match: bool = false)
Returns true if the given action matches this event and is released.

is_pressed

bool is_pressed()
Returns true if this input event is pressed.

is_echo

bool is_echo()
Returns true if this input event is an echo event (for key events).

as_text

String as_text()
Returns a String representation of the event.

Example Usage

func _input(event):
    if event.is_action_pressed("ui_accept"):
        print("Accept pressed")
    
    if event is InputEventKey:
        if event.is_pressed() and not event.is_echo():
            print("Key pressed: ", event.as_text())

Build docs developers (and LLMs) love