InputEventKey
A keyboard event: codes, side, Unicode and repetition.
Keep field purposes separate. Keycode describes a logical key, PhysicalKeycode its position for gameplay, KeyLabel its label and Unicode an event character code point. Editing one field neither derives the others nor injects a press into Input.
An InputMap binding should use one selector: Keycode, PhysicalKeycode or KeyLabel. A nonzero Keycode is the only selector compared: a mismatch does not fall back to PhysicalKeycode. PhysicalKeycode is used when Keycode = 0; KeyLabel is used when the first two are zero. A Unicode-only binding does not match a key press in the current engine. Binding matching is not equality of every event field.
Filter Echo for a one-time action. The complete example requires an already registered action; pass it an event from your input handler. Do not attach the static helper to an Entity.
using System;
using Reckfell;
public static class KeyboardEventExample
{
// Register the action in InputMap before calling this from an input handler.
public static bool IsInitialPress(InputEvent inputEvent, StringName action)
{
if (!InputMap.HasAction(action))
throw new ArgumentException("The action must already exist.", nameof(action));
return inputEvent is InputEventKey key && !key.Echo && key.IsActionPressed(action);
}
}For text input, do not treat every key as a committed character: Unicode contains neither the whole string nor a replacement for composition/IME handling. Actual layout data depends on the platform.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
InputEventKeyConstructor
public InputEventKey();Creates an event without submitting input. Key codes, Unicode and Location are 0; Pressed and Echo are false. Fields are independent: assigning PhysicalKeycode does not derive Keycode or Unicode.
Properties7
EchoProperty
public bool Echo { get; set; }Repeat marker for a held key. IsActionPressed filters such repeats by default; allowEcho permits them. Setting Echo neither creates a repeating timer nor controls the OS repeat rate.
KeyLabelProperty
public Key KeyLabel { get; set; }Platform-provided key label represented as a Key/character code. Used for binding matching only when both Keycode and PhysicalKeycode are 0. It is not the same concept as an entered character's Unicode.
KeycodeProperty
public Key Keycode { get; set; }Logical Key code for shortcuts and bindings. Has priority over PhysicalKeycode and KeyLabel when matching a binding. Zero means unset. Does not contain committed text input.
LocationProperty
public KeyLocation Location { get; set; }Key side: Left, Right or unspecified. A physical-key binding checks it when the binding specifies a side. Does not describe mouse position or change PhysicalKeycode itself.
PhysicalKeycodeProperty
public Key PhysicalKeycode { get; set; }Physical key-position code using the US QWERTY reference, useful for gameplay independent of the logical letter. Used by a binding when Keycode = 0; Location can additionally constrain the side. Assigning it does not press a key.
PressedProperty
public bool Pressed { get; set; }Event press state. Neither creates a physical press nor computes Echo. For a one-time action distinguish initial presses from repeats; check the event or action state for release.
UnicodeProperty
public long Unicode { get; set; }Event character code point when available; 0 means absent. This is neither a string nor a fallback InputMap action selector. The C# long type does not make every 64-bit value valid: supply valid Unicode code points. A non-BMP value such as U+1F600 does not fit in one C# char.
Methods19
AsTextKeyLabelstring
public string AsTextKeyLabel();Formats KeyLabel and modifiers for display. An unset code uses a textual marker. Does not turn the event into committed text and is unsuitable as a stable stored binding key.
stringReadable representation of the selected field and modifiers; text may depend on localization.
AsTextKeycodestring
public string AsTextKeycode();Formats Keycode and modifiers for display. An unset code uses a textual marker. Does not turn the event into committed text and is unsuitable as a stable stored binding key.
stringReadable representation of the selected field and modifiers; text may depend on localization.
AsTextLocationstring
public string AsTextLocation();The current implementation returns left for Location.Left, right for Location.Right, otherwise an empty string. Represents Location, not the key name.
stringleft, right or an empty string.
AsTextPhysicalKeycodestring
public string AsTextPhysicalKeycode();Formats PhysicalKeycode and modifiers for display. An unset code uses a textual marker. Does not turn the event into committed text and is unsuitable as a stable stored binding key.
stringReadable representation of the selected field and modifiers; text may depend on localization.
GetKeyLabelKey
public Key GetKeyLabel();Returns KeyLabel from the event without polling the keyboard again.
KeyStored KeyLabel value under the property contract.
GetKeyLabelWithModifiersKey
public Key GetKeyLabelWithModifiers();Combines KeyLabel and the current GetModifiersMask using bitwise OR. Does not select a fallback code from other fields or return text.
KeyA Key value containing KeyLabel and modifier bits.
GetKeycodeKey
public Key GetKeycode();Returns Keycode from the event without polling the keyboard again.
KeyStored Keycode value under the property contract.
GetKeycodeWithModifiersKey
public Key GetKeycodeWithModifiers();Combines Keycode and the current GetModifiersMask using bitwise OR. Does not select a fallback code from other fields or return text.
KeyA Key value containing Keycode and modifier bits.
GetLocationKeyLocation
public KeyLocation GetLocation();Returns Location from the event without polling the keyboard again.
KeyLocationStored Location value under the property contract.
GetPhysicalKeycodeKey
public Key GetPhysicalKeycode();Returns PhysicalKeycode from the event without polling the keyboard again.
KeyStored PhysicalKeycode value under the property contract.
GetPhysicalKeycodeWithModifiersKey
public Key GetPhysicalKeycodeWithModifiers();Combines PhysicalKeycode and the current GetModifiersMask using bitwise OR. Does not select a fallback code from other fields or return text.
KeyA Key value containing PhysicalKeycode and modifier bits.
GetUnicodelong
public long GetUnicode();Returns Unicode from the event without polling the keyboard again.
longStored Unicode value under the property contract.
SetEchovoid
public void SetEcho(bool echo);Sets Echo using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
echo | bool | — |
echoNew Echo value in the property's format.
SetKeyLabelvoid
public void SetKeyLabel(Key keyLabel);Sets KeyLabel using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
keyLabel | Key | — |
keyLabelNew KeyLabel value in the property's format.
SetKeycodevoid
public void SetKeycode(Key keycode);Sets Keycode using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
keycode | Key | — |
keycodeNew Keycode value in the property's format.
SetLocationvoid
public void SetLocation(KeyLocation location);Sets Location using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
location | KeyLocation | — |
locationNew Location value in the property's format.
SetPhysicalKeycodevoid
public void SetPhysicalKeycode(Key physicalKeycode);Sets PhysicalKeycode using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
physicalKeycode | Key | — |
physicalKeycodeNew PhysicalKeycode value in the property's format.
SetPressedvoid
public void SetPressed(bool pressed);Sets Pressed using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
pressed | bool | — |
pressedNew Pressed value in the property's format.
SetUnicodevoid
public void SetUnicode(long unicode);Sets Unicode using the property contract. Does not submit the event or derive the other key fields.
| Name | Type | Default |
|---|---|---|
unicode | long | — |
unicodeNew Unicode value in the property's format.