class_inputeventkey.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the InputEventKey.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_InputEventKey:
  6. InputEventKey
  7. =============
  8. **Inherits:** :ref:`InputEventWithModifiers<class_InputEventWithModifiers>` **<** :ref:`InputEvent<class_InputEvent>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Input event type for keyboard events.
  10. Description
  11. -----------
  12. Stores key presses on the keyboard. Supports key presses, key releases and :ref:`echo<class_InputEventKey_property_echo>` events.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/inputs/inputevent`
  16. Properties
  17. ----------
  18. +-------------------------+--------------------------------------------------------------------------+-----------+
  19. | :ref:`bool<class_bool>` | :ref:`echo<class_InputEventKey_property_echo>` | ``false`` |
  20. +-------------------------+--------------------------------------------------------------------------+-----------+
  21. | :ref:`int<class_int>` | :ref:`physical_scancode<class_InputEventKey_property_physical_scancode>` | ``0`` |
  22. +-------------------------+--------------------------------------------------------------------------+-----------+
  23. | :ref:`bool<class_bool>` | :ref:`pressed<class_InputEventKey_property_pressed>` | ``false`` |
  24. +-------------------------+--------------------------------------------------------------------------+-----------+
  25. | :ref:`int<class_int>` | :ref:`scancode<class_InputEventKey_property_scancode>` | ``0`` |
  26. +-------------------------+--------------------------------------------------------------------------+-----------+
  27. | :ref:`int<class_int>` | :ref:`unicode<class_InputEventKey_property_unicode>` | ``0`` |
  28. +-------------------------+--------------------------------------------------------------------------+-----------+
  29. Methods
  30. -------
  31. +-----------------------+----------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_physical_scancode_with_modifiers<class_InputEventKey_method_get_physical_scancode_with_modifiers>` **(** **)** |const| |
  33. +-----------------------+----------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_scancode_with_modifiers<class_InputEventKey_method_get_scancode_with_modifiers>` **(** **)** |const| |
  35. +-----------------------+----------------------------------------------------------------------------------------------------------------------------------+
  36. Property Descriptions
  37. ---------------------
  38. .. _class_InputEventKey_property_echo:
  39. - :ref:`bool<class_bool>` **echo**
  40. +-----------+-----------------+
  41. | *Default* | ``false`` |
  42. +-----------+-----------------+
  43. | *Setter* | set_echo(value) |
  44. +-----------+-----------------+
  45. | *Getter* | is_echo() |
  46. +-----------+-----------------+
  47. If ``true``, the key was already pressed before this event. It means the user is holding the key down.
  48. ----
  49. .. _class_InputEventKey_property_physical_scancode:
  50. - :ref:`int<class_int>` **physical_scancode**
  51. +-----------+------------------------------+
  52. | *Default* | ``0`` |
  53. +-----------+------------------------------+
  54. | *Setter* | set_physical_scancode(value) |
  55. +-----------+------------------------------+
  56. | *Getter* | get_physical_scancode() |
  57. +-----------+------------------------------+
  58. Key physical scancode, which corresponds to one of the :ref:`KeyList<enum_@GlobalScope_KeyList>` constants. Represent the physical location of a key on the 101/102-key US QWERTY keyboard.
  59. To get a human-readable representation of the ``InputEventKey``, use ``OS.get_scancode_string(event.physical_scancode)`` where ``event`` is the ``InputEventKey``.
  60. ----
  61. .. _class_InputEventKey_property_pressed:
  62. - :ref:`bool<class_bool>` **pressed**
  63. +-----------+--------------------+
  64. | *Default* | ``false`` |
  65. +-----------+--------------------+
  66. | *Setter* | set_pressed(value) |
  67. +-----------+--------------------+
  68. | *Getter* | is_pressed() |
  69. +-----------+--------------------+
  70. If ``true``, the key's state is pressed. If ``false``, the key's state is released.
  71. ----
  72. .. _class_InputEventKey_property_scancode:
  73. - :ref:`int<class_int>` **scancode**
  74. +-----------+---------------------+
  75. | *Default* | ``0`` |
  76. +-----------+---------------------+
  77. | *Setter* | set_scancode(value) |
  78. +-----------+---------------------+
  79. | *Getter* | get_scancode() |
  80. +-----------+---------------------+
  81. The key scancode, which corresponds to one of the :ref:`KeyList<enum_@GlobalScope_KeyList>` constants. Represent key in the current keyboard layout.
  82. To get a human-readable representation of the ``InputEventKey``, use ``OS.get_scancode_string(event.scancode)`` where ``event`` is the ``InputEventKey``.
  83. ----
  84. .. _class_InputEventKey_property_unicode:
  85. - :ref:`int<class_int>` **unicode**
  86. +-----------+--------------------+
  87. | *Default* | ``0`` |
  88. +-----------+--------------------+
  89. | *Setter* | set_unicode(value) |
  90. +-----------+--------------------+
  91. | *Getter* | get_unicode() |
  92. +-----------+--------------------+
  93. 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:`OS.set_ime_active<class_OS_method_set_ime_active>` for more information.
  94. Method Descriptions
  95. -------------------
  96. .. _class_InputEventKey_method_get_physical_scancode_with_modifiers:
  97. - :ref:`int<class_int>` **get_physical_scancode_with_modifiers** **(** **)** |const|
  98. Returns the physical scancode combined with modifier keys such as ``Shift`` or ``Alt``. See also :ref:`InputEventWithModifiers<class_InputEventWithModifiers>`.
  99. To get a human-readable representation of the ``InputEventKey`` with modifiers, use ``OS.get_scancode_string(event.get_physical_scancode_with_modifiers())`` where ``event`` is the ``InputEventKey``.
  100. ----
  101. .. _class_InputEventKey_method_get_scancode_with_modifiers:
  102. - :ref:`int<class_int>` **get_scancode_with_modifiers** **(** **)** |const|
  103. Returns the scancode combined with modifier keys such as ``Shift`` or ``Alt``. See also :ref:`InputEventWithModifiers<class_InputEventWithModifiers>`.
  104. To get a human-readable representation of the ``InputEventKey`` with modifiers, use ``OS.get_scancode_string(event.get_scancode_with_modifiers())`` where ``event`` is the ``InputEventKey``.
  105. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  106. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  107. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`