Struct KeyBinding
- Namespace
- MiniTui
- Assembly
- MiniTui.dll
One key combination, such as q, ctrl+r or shift+tab (§8.5).
[SuppressMessage("Naming", "CA1720:Identifier contains type name", Justification = "Name from the spec (§8.5): the character the binding matches.")]
public readonly record struct KeyBinding : IEquatable<KeyBinding>
- Implements
- Inherited Members
Constructors
KeyBinding(ConsoleKey, char?, ConsoleModifiers)
One key combination, such as q, ctrl+r or shift+tab (§8.5).
public KeyBinding(ConsoleKey Key, char? Char, ConsoleModifiers Modifiers)
Parameters
KeyConsoleKeyThe key, for named keys and Ctrl/Alt combinations. 0 for a plain character binding.
Charchar?The character, for a binding that matches what was typed. Null for named keys.
ModifiersConsoleModifiersThe modifiers that must be held. Ignored for plain character bindings, where Shift is part of the character.
Properties
Char
The character, for a binding that matches what was typed. Null for named keys.
public char? Char { get; init; }
Property Value
- char?
Key
The key, for named keys and Ctrl/Alt combinations. 0 for a plain character binding.
public ConsoleKey Key { get; init; }
Property Value
Modifiers
The modifiers that must be held. Ignored for plain character bindings, where Shift is part of the character.
public ConsoleModifiers Modifiers { get; init; }
Property Value
Methods
Matches(ConsoleKeyInfo)
True if key is this combination.
public bool Matches(ConsoleKeyInfo key)
Parameters
keyConsoleKeyInfo
Returns
Parse(string)
Parse one binding: (mod "+")* name, where mod is ctrl, alt or shift and name is a single
printable character or one of enter esc tab backspace delete insert up down left right home end pgup pgdn
space f1–f12. Case-insensitive, except that a character binding matches the character typed:
"R" and "shift+r" both match Shift+R.
public static KeyBinding Parse(string s)
Parameters
sstring
Returns
Exceptions
- FormatException
The text isn't a valid binding.
ToString()
The binding in the form Parse(string) accepts, for example ctrl+r.
public override string ToString()