Inherits: InputEventWithModifiers < InputEventFromWindow < InputEvent < Resource < RefCounted < Object
Represents a key on a keyboard being pressed or released.
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.
| ||
| ||
| ||
| ||
| ||
|
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 |
false
If true, the key was already pressed before this event. It means the user is holding the key down.
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 +-----+ +-----+
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" - keycode | Й | | ض | - "Й" and "ض" - key_label +-----+ +-----+
0
Represents the physical location of a key on the 101/102-key US QWERTY keyboard, which corresponds to one of the Key constants.
To get a human-readable representation of the InputEventKey, use OS.get_keycode_string in combination with DisplayServer.keyboard_get_keycode_from_physical:
func _input(event):
if event is InputEventKey:
var keycode = DisplayServer.keyboard_get_keycode_from_physical(event.physical_keycode)
print(OS.get_keycode_string(keycode))
C#public override void _Input(InputEvent @event)
{
if (@event is InputEventKey inputEventKey)
{
var keycode = DisplayServer.KeyboardGetKeycodeFromPhysical(inputEventKey.PhysicalKeycode);
GD.Print(OS.GetKeycodeString(keycode));
}
}
false
If true, the key's state is pressed. If false, the key's state is released.
0
The key Unicode character code (when relevant), shifted by modifier keys. Unicode character codes for composite characters and complex scripts may not be available unless IME input mode is active. See Window.set_ime_active for more information.
Returns a String representation of the event's key_label and modifiers.
Returns a String representation of the event's keycode and modifiers.
Returns a String representation of the event's physical_keycode and modifiers.
Returns the localized key label combined with modifier keys such as Shift or Alt. See also InputEventWithModifiers.
To get a human-readable representation of the InputEventKey with modifiers, use OS.get_keycode_string(event.get_key_label_with_modifiers()) where event is the InputEventKey.
Returns the Latin keycode combined with modifier keys such as Shift or Alt. See also 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.
Returns the physical keycode combined with modifier keys such as Shift or Alt. See also 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.
© 2014–present Juan Linietsky, Ariel Manzur and the Godot community
Licensed under the Creative Commons Attribution Unported License v3.0.
https://docs.godotengine.org/en/4.2/classes/class_inputeventkey.html