InputEvent
Inspect one input event, match actions and transform coordinates.
InputEvent is the base Resource for one event; its concrete type defines fields and behavior. event.IsActionPressed() concerns this event, while Input.IsActionPressed() reads current aggregate state. Constructing/querying an event injects no input into the game or OS.
IsAction checks a match rather than held state. IsActionReleased means matching inactive pressed-state: canceled mouse and an axis within deadzone can also return true. Check IsCanceled and concrete type when the cause matters. IsActionPressed filters echo by default.
IsMatch defaults exactMatch to true, while action queries default to false. Not universal equality: cross-subtype comparison can be asymmetric. XformedBy is subtype-dependent too: MouseMotion creates a copy while Key can return the same reference.
Input handling. Synthetic objects and temporary InputMap actions were tested on Windows; real keyboards/controllers, GUI routing and window-focus loss were not accepted here.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
DeviceProperty
public int Device { get; set; }Event device-ID metadata. Assignment neither selects hardware nor injects a press; the setter emits Changed. Special negative values exist. InputMap can filter bindings by Device, but direct IsMatch/Accumulate need not check it uniformly across subtypes.
Methods15
Accumulatebool
public bool Accumulate(InputEvent withEvent);Attempts to merge withEvent into this object, mutating the receiver on success. Injects no input and does not control global Input.UseAccumulatedInput. Base behavior is false; InputEventMouseMotion was tested: Relative/ScreenRelative are summed and Position/GlobalPosition/Velocity/ScreenVelocity use the latest event. Window/state/modifiers must be compatible. Direct MouseMotion.Accumulate does not check Device; filter devices yourself when separation matters. Not universal addition of every field or every event type.
| Name | Type | Default |
|---|---|---|
withEvent | InputEvent | — |
withEventSecond event to merge into the receiver; check subtype/Device if required by your protocol.
boolTrue after a successful receiver mutation, or false without a supported merge.
AsTextstring
public string AsText();Human-readable label of the concrete event; format/localization depend on subtype. Not for serialization, equality or a stable action ID. InputEventAction can show the first InputMap binding rather than its Action name; with no bindings it may be empty.
stringHuman-readable, possibly empty label without a stable format.
GetActionStrengthfloat
public float GetActionStrength(StringName action, bool exactMatch = false);Strength of the specified action in this event, not current aggregate Input state. Digital press is normally 1 and release 0; axes apply binding deadzone, while InputEventAction uses stored Strength only when Pressed. A nonmatching event returns 0. The action must exist in InputMap; an unknown name is diagnosed rather than providing a safe TryGet.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
actionExisting InputMap action name rather than a key code; use HasAction first for dynamic names.
exactMatchTrue requires exact subtype modifier/direction matching. IsMatch defaults to true; action queries default to false.
floatAction strength in this event, normally 0…1; also 0 for no match.
GetDeviceint
public int GetDevice();Returns this event Device metadata, not a connected-device or keyboard-state query.
intCurrent integer Device metadata.
IsActionbool
public bool IsAction(StringName action, bool exactMatch = false);Tests this event against an existing InputMap action regardless of pressed/released state or strength. Thus true can describe a release or an axis within deadzone. Default exactMatch=false allows extra modifiers under subtype rules. Changes no Input state and does not mean the action is currently held.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
actionExisting InputMap action name rather than a key code; use HasAction first for dynamic names.
exactMatchTrue requires exact subtype modifier/direction matching. IsMatch defaults to true; action queries default to false.
boolMatch result independent of pressed-state.
IsActionPressedbool
public bool IsActionPressed(StringName action, bool allowEcho = false, bool exactMatch = false);True when the event matches the action and its action pressed-state is active. Keyboard echo is excluded while allowEcho=false. Tests this event rather than global Input.IsActionJustPressed and consumes nothing. exactMatch controls modifier/direction matching by event type. Axis results depend on deadzone rather than movement alone.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
allowEcho | bool | false |
exactMatch | bool | false |
actionExisting InputMap action name rather than a key code; use HasAction first for dynamic names.
allowEchoTrue allows keyboard echo; false filters it in IsActionPressed.
exactMatchTrue requires exact subtype modifier/direction matching. IsMatch defaults to true; action queries default to false.
boolMatching active press with echo/deadzone rules applied.
IsActionReleasedbool
public bool IsActionReleased(StringName action, bool exactMatch = false);True for a matching action with inactive pressed-state. Not universal proof of a physical release: canceled mouse and an axis within deadzone also returned true. Check IsCanceled and concrete type when the cause matters. Nonexact key release can match a binding whose modifiers are no longer held. Not global Input.IsActionJustReleased.
| Name | Type | Default |
|---|---|---|
action | StringName | — |
exactMatch | bool | false |
actionExisting InputMap action name rather than a key code; use HasAction first for dynamic names.
exactMatchTrue requires exact subtype modifier/direction matching. IsMatch defaults to true; action queries default to false.
boolMatch with inactive pressed-state, not proof of a physical release.
IsActionTypebool
public bool IsActionType();Classifies a subtype as action-capable without checking a particular InputMap binding. A key returned true and MouseMotion false in the probe. Not IsAction, a Pressed check or permission to modify InputMap.
boolSubtype capability rather than a configured-action match.
IsCanceledbool
public bool IsCanceled();Returns the event cancellation flag. Canceled events have both base IsPressed and IsReleased false, while IsActionReleased can still return true through action matching. Cancellation differs from ordinary release. Actual window-focus cancellation transitions were not tested here.
boolStored event-cancellation flag.
IsEchobool
public bool IsEcho();Reports repeat/echo where supported by a subtype such as InputEventKey. Base behavior is false. Does not mean a double click or automatically repeating game action. IsActionPressed filters echo by default.
boolSubtype repeat/echo flag, false in the base.
IsMatchbool
public bool IsMatch(InputEvent @event, bool exactMatch = true);Compares by concrete subtype rules rather than every serialized field. Defaults to exactMatch=true, unlike IsAction. Pressed/strength/Device need not determine the result. Cross-subtype comparison can be asymmetric: InputEventAction can check a key through its InputMap action while the key need not match the Action in reverse. Not universal equality/hash.
| Name | Type | Default |
|---|---|---|
event | InputEvent | — |
exactMatch | bool | true |
eventAnother InputEvent; receiver-specific comparison can be asymmetric.
exactMatchTrue requires exact subtype modifier/direction matching. IsMatch defaults to true; action queries default to false.
boolMatch under receiver-subtype rules.
IsPressedbool
public bool IsPressed();Returns stored pressed && !canceled for this object. A manually created event need not reflect OS state. Use the corresponding action query for axis/deadzone behavior and Input for current held state. Does not check event type.
boolThis object pressed && !canceled.
IsReleasedbool
public bool IsReleased();Returns !pressed && !canceled. For button-like events this is a local released-state flag rather than proof of a real key/button transition, especially for synthetic or other subtypes. Distinct from IsActionReleased and global Input state.
boolThis object !pressed && !canceled.
SetDevicevoid
public void SetDevice(int device);Changes Device and emits Resource.Changed. Rebinds no action, connects no device and injects no OS event. Do not mutate a shared dispatched event while other code still needs its original metadata.
| Name | Type | Default |
|---|---|---|
device | int | — |
deviceDevice metadata including special values, not an OS handle.
XformedByInputEvent
public InputEvent XformedBy(Transform2D xform, Vector2? localOfs = default);Transforms coordinate-bearing events under subtype rules. MouseMotion was tested for a new copy, position = xform*(position+localOfs), basis-only Relative/Velocity transforms, and preserved ScreenRelative/ScreenVelocity/GlobalPosition. Key base behavior returns the same object and C# wrapper, so an independent copy is not guaranteed. Do not Dispose that alias while the original is used. Neither moves events between OS windows nor injects input.
| Name | Type | Default |
|---|---|---|
xform | Transform2D | — |
localOfs | Vector2? | default |
xform2D transform for local coordinates; screen-space fields may remain unchanged.
localOfsOffset added before xform for positional events; null/default means Vector2.Zero.
InputEventInputEvent: a new copy or the same shared object depending on subtype.
Fields and constants3
DeviceIdEmulationField
public const long DeviceIdEmulation = -1;Special value −1 for emulated events such as mouse from touch. Does not mean every manually created InputEventAction automatically gets this ID. Not an OS handle or player number.
DeviceIdKeyboardField
public const long DeviceIdKeyboard = 16;Value 16 used by InputEventKey construction as the keyboard category. Not a key index, scan code or guaranteed separation of multiple physical keyboards.
DeviceIdMouseField
public const long DeviceIdMouse = 32;Value 32 used by mouse-event construction. Not a button index or OS window ID. This value does not establish support for multiple physical mice.