Skip to content
ConsoleMonster
Struct

KeyChord

ConsoleMonster.Input

Namespace
ConsoleMonster.Input
Assembly
ConsoleMonster
Base
ValueType
Implements
IEquatable<KeyChord>
Modifiers
sealed

A key combination used by key bindings: either a key with exact modifiers (Ctrl+K, Shift+Tab, F1, PageDown) or a typed character (?, :, /) that matches however it was typed.

Inheritance

  • ValueType
  • KeyChord

Usage

Explore 40 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 28

Constructors

KeyChord 2 overloads
public KeyChord(ConsoleKey key, KeyModifiers modifiers = None) #

Creates a key chord.

Parameters

key System.ConsoleKey required
The key.
modifiers ConsoleMonster.Input.KeyModifiers = None optional
The modifiers.
public KeyChord(char character) #

Creates a character chord.

Parameters

character char required
The character.

Methods

Equals 2 overloads
public bool Equals(KeyChord other) #

Indicates whether the current object is equal to another object of the same type.

Parameters

other ConsoleMonster.Input.KeyChord required
An object to compare with this object.

Returns

bool true if the current object is equal to the other parameter; otherwise, false.
public override bool Equals(object? obj) #

Indicates whether this instance and a specified object are equal.

Parameters

obj object? required
The object to compare with the current instance.

Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.
public override int GetHashCode() #

Returns the hash code for this instance.

Returns

int A 32-bit signed integer that is the hash code for this instance.
public bool Matches(InputEvent input) #

Whether an event is this chord. A Latin letter or digit chord also matches the same key on another layout: a Cyrillic layout typing й on the Q key matches q, and a French layout typing & on the 1 key matches 1. A typed Latin character always matches exactly, so remapped layouts keep their labels.

Parameters

input ConsoleMonster.Input.InputEvent required
The event.

Returns

bool True on a match.
public static bool op_Equality(KeyChord left, KeyChord right) #

Equality.

Parameters

left ConsoleMonster.Input.KeyChord required
The left chord.
right ConsoleMonster.Input.KeyChord required
The right chord.

Returns

bool True when equal.
public static bool op_Inequality(KeyChord left, KeyChord right) #

Inequality.

Parameters

left ConsoleMonster.Input.KeyChord required
The left chord.
right ConsoleMonster.Input.KeyChord required
The right chord.

Returns

bool True when different.
public static KeyChord Parse(string text) #

Parses Ctrl+K,Alt+Enter, Shift+Tab, F5, PgDn, Space or a single character such as ?. Modifier and key names are case-insensitive.

Parameters

text string required
The text.

Returns

KeyChord The chord.
public override string ToString() #

The chord as people write it: Ctrl+K, Shift+Tab, ?.

Returns

string The name.
public static bool TryParse(string? text, out KeyChord chord) #

Parses a chord; see KeyChord.Parse.

Parameters

text string? required
The text.
chord ConsoleMonster.Input.KeyChord required
The chord.

Returns

bool Whether the text is a chord.

Properties

public ConsoleKey Key { get; } #

The key, or 0 for a character chord.

public char Char { get; } #

The character of a character chord, or '\0'.

public KeyModifiers Modifiers { get; } #

The modifiers of a key chord.

public bool IsCharacter { get; } #

Whether this is a character chord.