:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/InputEvent.xml. .. _class_InputEvent: InputEvent ========== **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` **Inherited By:** :ref:`InputEventAction`, :ref:`InputEventFromWindow`, :ref:`InputEventJoypadButton`, :ref:`InputEventJoypadMotion`, :ref:`InputEventMIDI`, :ref:`InputEventShortcut` Abstract base class for input events. .. rst-class:: classref-introduction-group Description ----------- Abstract base class of all types of input events. See :ref:`Node._input()`. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Using InputEvent <../tutorials/inputs/inputevent>` - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>` - `2D Dodge The Creeps Demo `__ - `3D Voxel Demo `__ .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------+-------------------------------------------------+-------+ | :ref:`int` | :ref:`device` | ``0`` | +-----------------------+-------------------------------------------------+-------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`accumulate`\ (\ with_event\: :ref:`InputEvent`\ ) | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`as_text`\ (\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_action_strength`\ (\ action\: :ref:`StringName`, exact_match\: :ref:`bool` = false\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_action`\ (\ action\: :ref:`StringName`, exact_match\: :ref:`bool` = false\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_action_pressed`\ (\ action\: :ref:`StringName`, allow_echo\: :ref:`bool` = false, exact_match\: :ref:`bool` = false\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_action_released`\ (\ action\: :ref:`StringName`, exact_match\: :ref:`bool` = false\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_action_type`\ (\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_canceled`\ (\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_echo`\ (\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_match`\ (\ event\: :ref:`InputEvent`, exact_match\: :ref:`bool` = true\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_pressed`\ (\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_released`\ (\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`InputEvent` | :ref:`xformed_by`\ (\ xform\: :ref:`Transform2D`, local_ofs\: :ref:`Vector2` = Vector2(0, 0)\ ) |const| | +-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Constants --------- .. _class_InputEvent_constant_DEVICE_ID_EMULATION: .. rst-class:: classref-constant **DEVICE_ID_EMULATION** = ``-1`` :ref:`🔗` Device ID used for emulated mouse input from a touchscreen, or for emulated touch input from a mouse. This can be used to distinguish emulated mouse input from physical mouse input, or emulated touch input from physical touch input. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_InputEvent_property_device: .. rst-class:: classref-property :ref:`int` **device** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_device**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_device**\ (\ ) The event's device ID. \ **Note:** :ref:`device` can be negative for special use cases that don't refer to devices physically present on the system. See :ref:`DEVICE_ID_EMULATION`. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_InputEvent_method_accumulate: .. rst-class:: classref-method :ref:`bool` **accumulate**\ (\ with_event\: :ref:`InputEvent`\ ) :ref:`🔗` Returns ``true`` if the given input event and this input event can be added together (only for events of type :ref:`InputEventMouseMotion`). The given input event's position, global position and speed will be copied. The resulting ``relative`` is a sum of both events. Both events' modifiers have to be identical. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_as_text: .. rst-class:: classref-method :ref:`String` **as_text**\ (\ ) |const| :ref:`🔗` Returns a :ref:`String` representation of the event. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_get_action_strength: .. rst-class:: classref-method :ref:`float` **get_action_strength**\ (\ action\: :ref:`StringName`, exact_match\: :ref:`bool` = false\ ) |const| :ref:`🔗` Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type :ref:`InputEventJoypadMotion`. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey` and :ref:`InputEventMouseButton` events, and the direction for :ref:`InputEventJoypadMotion` events. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_action: .. rst-class:: classref-method :ref:`bool` **is_action**\ (\ action\: :ref:`StringName`, exact_match\: :ref:`bool` = false\ ) |const| :ref:`🔗` Returns ``true`` if this input event matches a pre-defined action of any type. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey` and :ref:`InputEventMouseButton` events, and the direction for :ref:`InputEventJoypadMotion` events. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_action_pressed: .. rst-class:: classref-method :ref:`bool` **is_action_pressed**\ (\ action\: :ref:`StringName`, allow_echo\: :ref:`bool` = false, exact_match\: :ref:`bool` = false\ ) |const| :ref:`🔗` Returns ``true`` if the given action is being pressed (and is not an echo event for :ref:`InputEventKey` events, unless ``allow_echo`` is ``true``). Not relevant for events of type :ref:`InputEventMouseMotion` or :ref:`InputEventScreenDrag`. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey` and :ref:`InputEventMouseButton` events, and the direction for :ref:`InputEventJoypadMotion` events. \ **Note:** Due to keyboard ghosting, :ref:`is_action_pressed()` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_action_released: .. rst-class:: classref-method :ref:`bool` **is_action_released**\ (\ action\: :ref:`StringName`, exact_match\: :ref:`bool` = false\ ) |const| :ref:`🔗` Returns ``true`` if the given action is released (i.e. not pressed). Not relevant for events of type :ref:`InputEventMouseMotion` or :ref:`InputEventScreenDrag`. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey` and :ref:`InputEventMouseButton` events, and the direction for :ref:`InputEventJoypadMotion` events. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_action_type: .. rst-class:: classref-method :ref:`bool` **is_action_type**\ (\ ) |const| :ref:`🔗` Returns ``true`` if this input event's type is one that can be assigned to an input action. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_canceled: .. rst-class:: classref-method :ref:`bool` **is_canceled**\ (\ ) |const| :ref:`🔗` Returns ``true`` if this input event has been canceled. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_echo: .. rst-class:: classref-method :ref:`bool` **is_echo**\ (\ ) |const| :ref:`🔗` Returns ``true`` if this input event is an echo event (only for events of type :ref:`InputEventKey`). An echo event is a repeated key event sent when the user is holding down the key. Any other event type returns ``false``. \ **Note:** The rate at which echo events are sent is typically around 20 events per second (after holding down the key for roughly half a second). However, the key repeat delay/speed can be changed by the user or disabled entirely in the operating system settings. To ensure your project works correctly on all configurations, do not assume the user has a specific key repeat configuration in your project's behavior. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_match: .. rst-class:: classref-method :ref:`bool` **is_match**\ (\ event\: :ref:`InputEvent`, exact_match\: :ref:`bool` = true\ ) |const| :ref:`🔗` Returns ``true`` if the specified ``event`` matches this event. Only valid for action events i.e key (:ref:`InputEventKey`), button (:ref:`InputEventMouseButton` or :ref:`InputEventJoypadButton`), axis :ref:`InputEventJoypadMotion` or action (:ref:`InputEventAction`) events. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey` and :ref:`InputEventMouseButton` events, and the direction for :ref:`InputEventJoypadMotion` events. \ **Note:** Only considers the event configuration (such as the keyboard key or joypad axis), not state information like :ref:`is_pressed()`, :ref:`is_released()`, :ref:`is_echo()`, or :ref:`is_canceled()`. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_pressed: .. rst-class:: classref-method :ref:`bool` **is_pressed**\ (\ ) |const| :ref:`🔗` Returns ``true`` if this input event is pressed. Not relevant for events of type :ref:`InputEventMouseMotion` or :ref:`InputEventScreenDrag`. \ **Note:** Due to keyboard ghosting, :ref:`is_pressed()` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_is_released: .. rst-class:: classref-method :ref:`bool` **is_released**\ (\ ) |const| :ref:`🔗` Returns ``true`` if this input event is released. Not relevant for events of type :ref:`InputEventMouseMotion` or :ref:`InputEventScreenDrag`. .. rst-class:: classref-item-separator ---- .. _class_InputEvent_method_xformed_by: .. rst-class:: classref-method :ref:`InputEvent` **xformed_by**\ (\ xform\: :ref:`Transform2D`, local_ofs\: :ref:`Vector2` = Vector2(0, 0)\ ) |const| :ref:`🔗` Returns a copy of the given input event which has been offset by ``local_ofs`` and transformed by ``xform``. Relevant for events of type :ref:`InputEventMouseButton`, :ref:`InputEventMouseMotion`, :ref:`InputEventScreenTouch`, :ref:`InputEventScreenDrag`, :ref:`InputEventMagnifyGesture` and :ref:`InputEventPanGesture`. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`