Skip to content
ConsoleMonster

API Reference

Class

KeyBinding

Namespace ConsoleMonster.Interactive
Assembly ConsoleMonster
Modifiers sealed

A key binding: the keys, what they do and the words that describe them. Footers and the key map are generated from the active bindings, so what the screen says is always what the keys do.

Inheritance

  • Object
  • KeyBinding

Usage

Explore 2 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.

Returned or exposed by 2

Constructors

public KeyBinding(String label, Action action, params KeyChord[] chords) #

Creates a binding.

Parameters

label System.String requiredposition: 0
What the keys do ("select", "toggle").
action System.Action requiredposition: 1
The action.
chords ConsoleMonster.Input.KeyChord[] requiredposition: 2
The keys.

Methods

public static KeyBinding Create(String keys, String label, Action action) #
Returns: KeyBinding

Creates a binding from key names ("Ctrl+K", ":").

Parameters

keys System.String requiredposition: 0
The keys, as KeyChord.Parse accepts them.
label System.String requiredposition: 1
What the keys do.
action System.Action requiredposition: 2
The action.

Returns

The binding.

public String DisplayKeys() #
Returns: String

The key text as shown in footers: lower-case names (enter, ctrl+a), characters as typed.

Returns

The text.

public Boolean Matches(InputEvent input) #
Returns: Boolean

Whether an event triggers this binding.

Parameters

input ConsoleMonster.Input.InputEvent requiredposition: 0
The event.

Returns

True on a match.

Properties

public IReadOnlyList<KeyChord> Chords { get; } #

The keys.

public String Label { get; } #

What the keys do.

public Action Action { get; } #

The action.

public String? KeyText { get; set; } #

How the keys are shown (for example ↑↓); null shows the first chord.

public String Group { get; set; } #

The heading the binding is listed under in the key map.

public Int32 Order { get; set; } #

Footer priority: lower values are shown first and dropped last when space runs out.

public Boolean InFooter { get; set; } #

Whether the footer shows the binding (the key map always lists it).