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.
Checking the stable version of the documentation...
InputEventKey¶
Inherits: InputEventWithModifiers < InputEventFromWindow < InputEvent < Resource < RefCounted < Object
Represents a key on a keyboard being pressed or released.
Description¶
An input event for keys on a keyboard. Supports key presses, key releases and echo events. It can also be received in Node._unhandled_key_input.
Note: Events received from the keyboard usually have all properties set. Event mappings should have only one of the keycode, physical_keycode or unicode set.
When events are compared, properties are checked in the following priority - keycode, physical_keycode and unicode. Events with the first matching value will be considered equal.
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
||
|
Methods¶
as_text_key_label ( ) const |
|
as_text_keycode ( ) const |
|
as_text_physical_keycode ( ) const |
|
get_key_label_with_modifiers ( ) const |
|
get_keycode_with_modifiers ( ) const |
|
get_physical_keycode_with_modifiers ( ) const |
Property Descriptions¶
bool echo = false
If true
, the key was already pressed before this event. It means the user is holding the key down.
Key key_label = 0
Represents the localized label printed on the key in the current keyboard layout, which corresponds to one of the Key constants or any valid Unicode character.
For keyboard layouts with a single label on the key, it is equivalent to keycode.
To get a human-readable representation of the InputEventKey, use OS.get_keycode_string(event.key_label)
where event
is the InputEventKey.
+-----+ +-----+
| Q | | Q | - "Q" - keycode
| Й | | ض | - "Й" and "ض" - key_label
+-----+ +-----+
Key keycode = 0
Latin label printed on the key in the current keyboard layout, which corresponds to one of the Key constants.
To get a human-readable representation of the InputEventKey, use OS.get_keycode_string(event.keycode)
where event
is the InputEventKey.
+-----+ +-----+
| Q | | Q | - "Q"