Skip to content

Hex1bKeyEvent

Namespace: Hex1b.Input

Assembly: Hex1b.dll

A keyboard input event that gets routed to the focused node.

csharp
public sealed record Hex1bKeyEvent : Hex1bEvent, IEquatable<Hex1bEvent>, IEquatable<Hex1bKeyEvent>

Inheritance

ObjectHex1bEventHex1bKeyEvent

Implements

Constructors

Hex1bKeyEvent(Hex1bKey, char, Hex1bModifiers)

Legacy constructor for single character input.

Parameters:

csharp
public Hex1bKeyEvent(Hex1bKey key, char character, Hex1bModifiers modifiers)

Hex1bKeyEvent(Hex1bKey, string, Hex1bModifiers)

A keyboard input event that gets routed to the focused node.

Parameters:

  • Key (Hex1bKey): The key that was pressed.
  • Text (String): The text produced by the keypress (may be empty for non-printable keys). Supports multi-char input like emojis.
  • Modifiers (Hex1bModifiers): The modifier keys held during the keypress.
csharp
public Hex1bKeyEvent(Hex1bKey Key, string Text, Hex1bModifiers Modifiers)

Properties

Alt

Returns true if the Alt modifier is active.

Returns: Boolean

csharp
public bool Alt { get; }

Character

Gets the first character of the text, or '\0' if empty. For compatibility with code expecting a single char.

Returns: Char

csharp
public char Character { get; }

Control

Returns true if the Control modifier is active.

Returns: Boolean

csharp
public bool Control { get; }

IsPrintable

Returns true if the key produces printable text.

Returns: Boolean

csharp
public bool IsPrintable { get; }

Key

The key that was pressed.

Returns: Hex1bKey

csharp
public Hex1bKey Key { get; init; }

Modifiers

The modifier keys held during the keypress.

Returns: Hex1bModifiers

csharp
public Hex1bModifiers Modifiers { get; init; }

Shift

Returns true if the Shift modifier is active.

Returns: Boolean

csharp
public bool Shift { get; }

Text

The text produced by the keypress (may be empty for non-printable keys). Supports multi-char input like emojis.

Returns: String

csharp
public string Text { get; init; }

Methods

FromText(string)

Creates an event for text input with no modifiers (e.g., paste, emoji).

Parameters:

Returns: Hex1bKeyEvent

csharp
public static Hex1bKeyEvent FromText(string text)

Plain(Hex1bKey, char)

Creates an event for a simple key press with no modifiers.

Parameters:

Returns: Hex1bKeyEvent

csharp
public static Hex1bKeyEvent Plain(Hex1bKey key, char character = '\0')

WithAlt(Hex1bKey, char)

Creates an event for a key press with Alt modifier.

Parameters:

Returns: Hex1bKeyEvent

csharp
public static Hex1bKeyEvent WithAlt(Hex1bKey key, char character = '\0')

WithCtrl(Hex1bKey, char)

Creates an event for a key press with Control modifier.

Parameters:

Returns: Hex1bKeyEvent

csharp
public static Hex1bKeyEvent WithCtrl(Hex1bKey key, char character = '\0')

WithShift(Hex1bKey, char)

Creates an event for a key press with Shift modifier.

Parameters:

Returns: Hex1bKeyEvent

csharp
public static Hex1bKeyEvent WithShift(Hex1bKey key, char character = '\0')

Released under the MIT License.