InputEventKey

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

An input event for keys on a keyboard. Supports key presses, key releases and Echo events. It can also be received in Node.UnhandledKeyInput.

Note: Events received from the keyboard usually have all properties set. Event mappings should have only one of the Keycode, PhysicalKeycode or Unicode set.

When events are compared, properties are checked in the following priority - Keycode, PhysicalKeycode and Unicode. Events with the first matching value will be considered equal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsInputEventKey() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsInputEvent

func (self *Extension[T]) AsInputEvent() InputEvent.Instance

func (*Extension[T]) AsInputEventFromWindow

func (self *Extension[T]) AsInputEventFromWindow() InputEventFromWindow.Instance

func (*Extension[T]) AsInputEventKey

func (self *Extension[T]) AsInputEventKey() Instance

func (*Extension[T]) AsInputEventWithModifiers

func (self *Extension[T]) AsInputEventWithModifiers() InputEventWithModifiers.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.InputEventKey

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsInputEvent

func (self Instance) AsInputEvent() InputEvent.Instance

func (Instance) AsInputEventFromWindow

func (self Instance) AsInputEventFromWindow() InputEventFromWindow.Instance

func (Instance) AsInputEventKey

func (self Instance) AsInputEventKey() Instance

func (Instance) AsInputEventWithModifiers

func (self Instance) AsInputEventWithModifiers() InputEventWithModifiers.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTextKeyLabel

func (self Instance) AsTextKeyLabel() string

Returns a string representation of the event's KeyLabel and modifiers.

func (Instance) AsTextKeycode

func (self Instance) AsTextKeycode() string

Returns a string representation of the event's Keycode and modifiers.

func (Instance) AsTextLocation

func (self Instance) AsTextLocation() string

Returns a string representation of the event's Location. This will be a blank string if the event is not specific to a location.

func (Instance) AsTextPhysicalKeycode

func (self Instance) AsTextPhysicalKeycode() string

Returns a string representation of the event's PhysicalKeycode and modifiers.

func (Instance) GetKeyLabelWithModifiers

func (self Instance) GetKeyLabelWithModifiers() Input.Key

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.

func (Instance) GetKeycodeWithModifiers

func (self Instance) GetKeycodeWithModifiers() Input.Key

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.

func (Instance) GetPhysicalKeycodeWithModifiers

func (self Instance) GetPhysicalKeycodeWithModifiers() Input.Key

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.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) KeyLabel

func (self Instance) KeyLabel() Input.Key

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.

func (Instance) Keycode

func (self Instance) Keycode() Input.Key

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.

func (Instance) Location

func (self Instance) Location() Input.KeyLocation

Represents the location of a key which has both left and right versions, such as Shift or Alt.

func (Instance) PhysicalKeycode

func (self Instance) PhysicalKeycode() Input.Key

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.GetKeycodeString in combination with DisplayServer.KeyboardGetKeycodeFromPhysical:

func (Instance) SetEcho

func (self Instance) SetEcho(value bool)

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.

func (Instance) SetKeyLabel

func (self Instance) SetKeyLabel(value Input.Key)

SetKeyLabel sets the property returned by [GetKeyLabel].

func (Instance) SetKeycode

func (self Instance) SetKeycode(value Input.Key)

SetKeycode sets the property returned by [GetKeycode].

func (Instance) SetLocation

func (self Instance) SetLocation(value Input.KeyLocation)

SetLocation sets the property returned by [GetLocation].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPhysicalKeycode

func (self Instance) SetPhysicalKeycode(value Input.Key)

SetPhysicalKeycode sets the property returned by [GetPhysicalKeycode].

func (Instance) SetPressed

func (self Instance) SetPressed(value bool)

If true, the key's state is pressed. If false, the key's state is released.

func (Instance) SetUnicode

func (self Instance) SetUnicode(value int)

SetUnicode sets the property returned by [GetUnicode].

func (Instance) Unicode

func (self Instance) Unicode() int

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.SetImeActive for more information.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL