Files
godot-docs/classes/class_inputeventkey.rst
2022-07-27 13:59:06 +02:00

163 lines
7.6 KiB
ReStructuredText

: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/InputEventKey.xml.
.. _class_InputEventKey:
InputEventKey
=============
**Inherits:** :ref:`InputEventWithModifiers<class_InputEventWithModifiers>` **<** :ref:`InputEventFromWindow<class_InputEventFromWindow>` **<** :ref:`InputEvent<class_InputEvent>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Input event type for keyboard events.
Description
-----------
Stores key presses on the keyboard. Supports key presses, key releases and :ref:`echo<class_InputEventKey_property_echo>` events.
Tutorials
---------
- :doc:`InputEvent <../tutorials/inputs/inputevent>`
Properties
----------
+-----------------------------------+------------------------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`echo<class_InputEventKey_property_echo>` | ``false`` |
+-----------------------------------+------------------------------------------------------------------------+-----------+
| :ref:`Key<enum_@GlobalScope_Key>` | :ref:`keycode<class_InputEventKey_property_keycode>` | ``0`` |
+-----------------------------------+------------------------------------------------------------------------+-----------+
| :ref:`Key<enum_@GlobalScope_Key>` | :ref:`physical_keycode<class_InputEventKey_property_physical_keycode>` | ``0`` |
+-----------------------------------+------------------------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`pressed<class_InputEventKey_property_pressed>` | ``false`` |
+-----------------------------------+------------------------------------------------------------------------+-----------+
| :ref:`int<class_int>` | :ref:`unicode<class_InputEventKey_property_unicode>` | ``0`` |
+-----------------------------------+------------------------------------------------------------------------+-----------+
Methods
-------
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Key<enum_@GlobalScope_Key>` | :ref:`get_keycode_with_modifiers<class_InputEventKey_method_get_keycode_with_modifiers>` **(** **)** |const| |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Key<enum_@GlobalScope_Key>` | :ref:`get_physical_keycode_with_modifiers<class_InputEventKey_method_get_physical_keycode_with_modifiers>` **(** **)** |const| |
+-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
Property Descriptions
---------------------
.. _class_InputEventKey_property_echo:
- :ref:`bool<class_bool>` **echo**
+-----------+-----------------+
| *Default* | ``false`` |
+-----------+-----------------+
| *Setter* | set_echo(value) |
+-----------+-----------------+
| *Getter* | is_echo() |
+-----------+-----------------+
If ``true``, the key was already pressed before this event. It means the user is holding the key down.
----
.. _class_InputEventKey_property_keycode:
- :ref:`Key<enum_@GlobalScope_Key>` **keycode**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_keycode(value) |
+-----------+--------------------+
| *Getter* | get_keycode() |
+-----------+--------------------+
The key keycode, which corresponds to one of the :ref:`Key<enum_@GlobalScope_Key>` constants. Represent key in the current keyboard layout.
To get a human-readable representation of the ``InputEventKey``, use ``OS.get_keycode_string(event.keycode)`` where ``event`` is the ``InputEventKey``.
----
.. _class_InputEventKey_property_physical_keycode:
- :ref:`Key<enum_@GlobalScope_Key>` **physical_keycode**
+-----------+-----------------------------+
| *Default* | ``0`` |
+-----------+-----------------------------+
| *Setter* | set_physical_keycode(value) |
+-----------+-----------------------------+
| *Getter* | get_physical_keycode() |
+-----------+-----------------------------+
Key physical keycode, which corresponds to one of the :ref:`Key<enum_@GlobalScope_Key>` constants. Represent the physical location of a key on the 101/102-key US QWERTY keyboard.
To get a human-readable representation of the ``InputEventKey``, use ``OS.get_keycode_string(event.keycode)`` where ``event`` is the ``InputEventKey``.
----
.. _class_InputEventKey_property_pressed:
- :ref:`bool<class_bool>` **pressed**
+-----------+--------------------+
| *Default* | ``false`` |
+-----------+--------------------+
| *Setter* | set_pressed(value) |
+-----------+--------------------+
| *Getter* | is_pressed() |
+-----------+--------------------+
If ``true``, the key's state is pressed. If ``false``, the key's state is released.
----
.. _class_InputEventKey_property_unicode:
- :ref:`int<class_int>` **unicode**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_unicode(value) |
+-----------+--------------------+
| *Getter* | get_unicode() |
+-----------+--------------------+
The key Unicode identifier (when relevant). Unicode identifiers for the composite characters and complex scripts may not be available unless IME input mode is active. See :ref:`Window.set_ime_active<class_Window_method_set_ime_active>` for more information.
Method Descriptions
-------------------
.. _class_InputEventKey_method_get_keycode_with_modifiers:
- :ref:`Key<enum_@GlobalScope_Key>` **get_keycode_with_modifiers** **(** **)** |const|
Returns the keycode combined with modifier keys such as :kbd:`Shift` or :kbd:`Alt`. See also :ref:`InputEventWithModifiers<class_InputEventWithModifiers>`.
To get a human-readable representation of the ``InputEventKey`` with modifiers, use ``OS.get_keycode_string(event.get_keycode_with_modifiers())`` where ``event`` is the ``InputEventKey``.
----
.. _class_InputEventKey_method_get_physical_keycode_with_modifiers:
- :ref:`Key<enum_@GlobalScope_Key>` **get_physical_keycode_with_modifiers** **(** **)** |const|
Returns the physical keycode combined with modifier keys such as :kbd:`Shift` or :kbd:`Alt`. See also :ref:`InputEventWithModifiers<class_InputEventWithModifiers>`.
To get a human-readable representation of the ``InputEventKey`` with modifiers, use ``OS.get_keycode_string(event.get_physical_keycode_with_modifiers())`` where ``event`` is the ``InputEventKey``.
.. |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.)`