InputEventKey
Hereda: InputEventWithModifiers < InputEventFromWindow < InputEvent < Resource < RefCounted < Object
Representa una tecla de un teclado que se está pulsando o soltando.
Descripción
Un evento de entrada para las teclas de un teclado. Admite pulsaciones de teclas, liberaciones de teclas y eventos echo. También se puede recibir en Node._unhandled_key_input().
Nota: Los eventos recibidos del teclado suelen tener todas las propiedades establecidas. Las asignaciones de eventos deben tener solo uno de los keycode, physical_keycode o unicode establecidos.
Cuando se comparan los eventos, las propiedades se comprueban en el siguiente orden de prioridad: keycode, physical_keycode y unicode. Los eventos con el primer valor coincidente se considerarán iguales.
Tutoriales
Propiedades
|
||
|
||
|
||
|
||
|
||
|
||
|
Métodos
as_text_key_label() const |
|
as_text_keycode() const |
|
as_text_location() const |
|
as_text_physical_keycode() const |
|
get_key_label_with_modifiers() const |
|
get_keycode_with_modifiers() const |
|
Descripciones de Propiedades
If true, the key was already pressed before this event. An echo event is a repeated key event sent when the user is holding down the key.
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.
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
+-----+ +-----+
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
+-----+ +-----+
KeyLocation location = 0 🔗
void set_location(value: KeyLocation)
KeyLocation get_location()
Represents the location of a key which has both left and right versions, such as Shift or Alt.
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))
public override void _Input(InputEvent @event)
{
if (@event is InputEventKey inputEventKey)
{
var keycode = DisplayServer.KeyboardGetKeycodeFromPhysical(inputEventKey.PhysicalKeycode);
GD.Print(OS.GetKeycodeString(keycode));
}
}
Si es true, se pulsa el estado de la tecla. Si es false, el estado de la tecla se libera.
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.
Descripciones de Métodos
String as_text_key_label() const 🔗
Devuelve una representación String de la key_label y los modificadores del evento.
String as_text_keycode() const 🔗
Devuelve una representación String de la keycode y los modificadores del evento.
String as_text_location() const 🔗
Returns a String representation of the event's location. This will be a blank string if the event is not specific to a location.
String as_text_physical_keycode() const 🔗
Returns a String representation of the event's physical_keycode and modifiers.
Key get_key_label_with_modifiers() const 🔗
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.
Key get_keycode_with_modifiers() const 🔗
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.
Key get_physical_keycode_with_modifiers() const 🔗
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.