KeyBinding
ConsoleMonster.Interactive
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 99 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 29
- Property AppScreen.Bindings
- Property Breadcrumb.Bindings
- Property Button.Bindings
- Property ChartView.Bindings
- Property Collapsible.Bindings
- Property ConsoleAppOptions.KeyBindings
- Property DataGrid.Bindings
- Property DatePicker.Bindings
- Property InputControl.Bindings
- Extension method KeyBinding.AvailableWhen
- Extension method KeyBinding.Group
- Extension method KeyBinding.InFooter
- Extension method KeyBinding.KeyText
- Extension method KeyBinding.Order
- Method KeyBinding.Create
- Method KeyBinding.Numbered
- Method KeyBindingFluent.AvailableWhen
- Method KeyBindingFluent.Group
- Method KeyBindingFluent.InFooter
- Method KeyBindingFluent.KeyText
- Method KeyBindingFluent.Order
- Property LogViewport.Bindings
- Property Menu.KeyBindings
- Property Outline.Bindings
- Property Select.Bindings
- Property SelectionInputBase.Bindings
- Property TextInput.Bindings
- Property Toggle.Bindings
- Property TreeSelect.Bindings
Accepted by parameters 70
- Extension method AppScreen.Binding
- Extension method AppScreen.Bindings
- Method AppScreenFluent.Binding
- Method AppScreenFluent.Bindings
- Extension method Breadcrumb.Binding
- Extension method Breadcrumb.Bindings
- Method BreadcrumbFluent.Binding
- Method BreadcrumbFluent.Bindings
- Extension method Button.Binding
- Extension method Button.Bindings
- Method ButtonFluent.Binding
- Method ButtonFluent.Bindings
- Extension method ChartView.Binding
- Extension method ChartView.Bindings
- Method ChartViewFluent.Binding
- Method ChartViewFluent.Bindings
- Extension method Collapsible.Binding
- Extension method Collapsible.Bindings
- Method CollapsibleFluent.Binding
- Method CollapsibleFluent.Bindings
- Extension method ConsoleAppOptions.KeyBinding
- Extension method ConsoleAppOptions.KeyBindings
- Method ConsoleAppOptionsFluent.KeyBinding
- Method ConsoleAppOptionsFluent.KeyBindings
- Extension method DataGrid.Binding
- Extension method DataGrid.Bindings
- Method DataGridFluent.Binding
- Method DataGridFluent.Bindings
- Extension method DatePicker.Binding
- Extension method DatePicker.Bindings
- Method DatePickerFluent.Binding
- Method DatePickerFluent.Bindings
- Extension method KeyBinding.AvailableWhen
- Extension method KeyBinding.Group
- Extension method KeyBinding.InFooter
- Extension method KeyBinding.KeyText
- Extension method KeyBinding.Order
- Method KeyBindingFluent.AvailableWhen
- Method KeyBindingFluent.Group
- Method KeyBindingFluent.InFooter
- Method KeyBindingFluent.KeyText
- Method KeyBindingFluent.Order
- Extension method LogViewport.Binding
- Extension method LogViewport.Bindings
- Method LogViewportFluent.Binding
- Method LogViewportFluent.Bindings
- Extension method Menu.KeyBinding
- Extension method Menu.KeyBindings
- Method MenuFluent.KeyBinding
- Method MenuFluent.KeyBindings
- Extension method Outline.Binding
- Extension method Outline.Bindings
- Method OutlineFluent.Binding
- Method OutlineFluent.Bindings
- Extension method Select.Binding
- Extension method Select.Bindings
- Method SelectFluent.Binding
- Method SelectFluent.Bindings
- Extension method TextInput.Binding
- Extension method TextInput.Bindings
- Method TextInputFluent.Binding
- Method TextInputFluent.Bindings
- Extension method Toggle.Binding
- Extension method Toggle.Bindings
- Method ToggleFluent.Binding
- Method ToggleFluent.Bindings
- Extension method TreeSelect.Binding
- Extension method TreeSelect.Bindings
- Method TreeSelectFluent.Binding
- Method TreeSelectFluent.Bindings
Constructors
public KeyBinding(string label, Action action, params KeyChord[] chords) #Creates a binding.
Parameters
- label string
- What the keys do ("select", "toggle").
- action System.Action
- The action.
- chords ConsoleMonster.Input.KeyChord[]
- The keys.
Methods
public static KeyBinding Create(string keys, string label, Action action) #Creates a binding from key names ("Ctrl+K", ":").
Parameters
- keys string
- The keys, as KeyChord.Parse accepts them.
- label string
- What the keys do.
- action System.Action
- The action.
public string DisplayKeys() #The key text as shown in footers: lower-case names (enter, ctrl+a), characters as typed.
Returns
string The text.public bool Matches(InputEvent input) #Whether an event triggers this binding.
Parameters
- input ConsoleMonster.Input.InputEvent
- The event.
Returns
bool True on a match.public static KeyBinding Numbered(string label, Func<int> count, Action<int> open) #Opens numbered items: 1-9 open at once, and with ten or more items the digits build the number (1 then 2 opens 12). A digit that could still start a larger number waits; Enter opens it, Escape or any other key forgets it. The footer shows 1-N, or the digits typed so far.
Parameters
- label string
- What opening does ("open").
- count System.Func<int>
- The current number of items; read on every key.
- open System.Action<int>
- Opens the one-based item number.
Inherited Methods
Properties
public string? KeyText { get; set; } #How the keys are shown (for example ↑↓); null shows the first chord.
public Func<bool>? Available { get; set; } #Fluent("AvailableWhen")Whether the binding can run now; null means always. An unavailable binding stays in the footer dimmed and its keys do nothing, so they never fall through to another binding the footer does not show.
public string Group { get; set; } #The heading the binding is listed under in the key map.
public int Order { get; set; } #Footer priority: lower values are shown first and dropped last when space runs out.
Extension Methods
public static KeyBinding AvailableWhen(KeyBinding keyBinding, Func<bool>? value) #Sets KeyBinding.Available: Whether the binding can run now; null means always. An unavailable binding stays in the footer dimmed and its keys do nothing, so they never fall through to another binding the footer does not show.
Parameters
- keyBinding ConsoleMonster.Interactive.KeyBinding
- The instance.
- value System.Func<bool>?
- The callback.
Examples
// C# initializer or property // C# fluent
keyBinding.Available = value; keyBinding.AvailableWhen(value);public static KeyBinding Group(KeyBinding keyBinding, string value) #Sets KeyBinding.Group: The heading the binding is listed under in the key map.
Parameters
- keyBinding ConsoleMonster.Interactive.KeyBinding
- The instance.
- value string
- The value.
Examples
// C# initializer or property // C# fluent
keyBinding.Group = value; keyBinding.Group(value);public static KeyBinding KeyText(KeyBinding keyBinding, string? value) #Sets KeyBinding.KeyText: How the keys are shown (for example ↑↓); null shows the first chord.
Parameters
- keyBinding ConsoleMonster.Interactive.KeyBinding
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
keyBinding.KeyText = value; keyBinding.KeyText(value);public static KeyBinding Order(KeyBinding keyBinding, int value) #Sets KeyBinding.Order: Footer priority: lower values are shown first and dropped last when space runs out.
Parameters
- keyBinding ConsoleMonster.Interactive.KeyBinding
- The instance.
- value int
- The value.
Examples
// C# initializer or property // C# fluent
keyBinding.Order = value; keyBinding.Order(value);