KeyStroke struct
Namespace: Arlecchino.Input · Assembly: Arlecchino.Core
One key and the modifiers held with it, which is the smallest thing a binding can be made of. A KeyBinding is one of these plus its alternatives and its finishing key.
public readonly struct KeyStroke : IEquatable<KeyStroke>
Implements IEquatable<T><KeyStroke>
Constructors
| Member | Summary |
|---|---|
KeyStroke(char) | A stroke on a character rather than on a key, which is the only way to name punctuation. It answers on every layout that can type that character, whatever the keyboard does to produce it. |
KeyStroke(ConsoleKey, KeyModifiers) | One key and the modifiers held with it, which is the smallest thing a binding can be made of. A KeyBinding is one of these plus its alternatives and its finishing key. |
Properties
| Member | Summary |
|---|---|
Character | The character this stroke answers to, or '\0' when it is a stroke on a key. |
IsNone | Whether the stroke is unset and therefore stands for no key at all. |
Key | The key itself. |
Modifiers | Modifiers that must be held, exactly. |
Methods
| Member | Summary |
|---|---|
Deconstruct(out ConsoleKey, out KeyModifiers) | |
Matches(KeyPress) | Whether a key press is this stroke, by the key where one was reported and by the character otherwise. A key that answers to two names matches under either, and a stroke on a character forgives Shift. |
Replacing(KeyModifiers, KeyModifiers) | The same stroke with one modifier put in place of another. |
ToString() | How the stroke is shown to the user — Ctrl+S, Alt+←, Esc. The palette and the hints box display this, so a rebound key relabels itself everywhere. |
Constructors in detail
KeyStroke(char)
public KeyStroke(char character);
A stroke on a character rather than on a key, which is the only way to name punctuation. It answers on every layout that can type that character, whatever the keyboard does to produce it.
Parameters
| Name | Type | Description |
|---|---|---|
character | char | The character to answer to. |
KeyStroke(ConsoleKey, KeyModifiers)
public KeyStroke(ConsoleKey Key, KeyModifiers Modifiers = None);
One key and the modifiers held with it, which is the smallest thing a binding can be made of. A KeyBinding is one of these plus its alternatives and its finishing key.
Parameters
| Name | Type | Description |
|---|---|---|
Key | ConsoleKey | The key itself. |
Modifiers | KeyModifiers | Modifiers that must be held, exactly. |
Properties in detail
Character
public char Character { get; }
The character this stroke answers to, or '\0' when it is a stroke on a key.
Type char
IsNone
public bool IsNone { get; }
Whether the stroke is unset and therefore stands for no key at all.
Type bool
Key
public ConsoleKey Key { get; init; }
The key itself.
Type ConsoleKey
Modifiers
public KeyModifiers Modifiers { get; init; }
Modifiers that must be held, exactly.
Type KeyModifiers
Methods in detail
Deconstruct(out ConsoleKey, out KeyModifiers)
public void Deconstruct(out ConsoleKey Key, out KeyModifiers Modifiers);
Parameters
| Name | Type | Description |
|---|---|---|
Key | ConsoleKey | |
Modifiers | KeyModifiers |
Matches(KeyPress)
public bool Matches(KeyPress press);
Whether a key press is this stroke, by the key where one was reported and by the character otherwise. A key that answers to two names matches under either, and a stroke on a character forgives Shift.
Parameters
| Name | Type | Description |
|---|---|---|
press | KeyPress | The key that was pressed. |
Returns bool — true when the press is this combination.
Replacing(KeyModifiers, KeyModifiers)
public KeyStroke Replacing(KeyModifiers from, KeyModifiers to);
The same stroke with one modifier put in place of another.
Parameters
| Name | Type | Description |
|---|---|---|
from | KeyModifiers | The modifier to take out. |
to | KeyModifiers | The modifier to put in its place. |
Returns KeyStroke — The rewritten stroke, or this one when the modifier is not held.
ToString()
public override string ToString();
How the stroke is shown to the user — Ctrl+S, Alt+←, Esc. The palette and the hints box display this, so a rebound key relabels itself everywhere.
Returns string — The readable form, or an empty string when the stroke is unset.