Namespace Terminal.Gui.Input
Keyboard, mouse, and command processing.
The Input namespace provides input handling for keyboard events, mouse interactions, and the command execution framework.
Key Types
- Key - Keyboard input with modifier support (Ctrl, Alt, Shift)
- Mouse - Mouse event data (position, buttons, modifiers)
- Command - Standard application commands enum
- KeyBinding / MouseBinding - Associates input with commands
- Responder - Base class for input handling
Command Pattern
Views handle input through commands:
// 1. Add command handlers
AddCommand (Command.Accept, ctx => { /* handle */ return true; });
AddCommand (Command.Cancel, ctx => { /* handle */ return true; });
// 2. Bind keys to commands
KeyBindings.Add (Key.Enter, Command.Accept);
KeyBindings.Add (Key.Esc, Command.Cancel);
// 3. Bind mouse to commands
MouseBindings.Add (MouseFlags.Button1Clicked, Command.Accept);
Key Modifiers
Key.A.WithCtrl // Ctrl+A
Key.A.WithAlt // Alt+A
Key.A.WithShift // Shift+A (uppercase)
Key.F1.WithCtrl.WithShift // Ctrl+Shift+F1
See Also
Classes
- CommandEventArgs
Event arguments for Command events. Set Handled to true to indicate a command was handled.
- GrabMouseEventArgs
Provides data for mouse grab-related events (GrabbingMouse and UnGrabbingMouse).
- InputBindings<TEvent, TBinding>
Abstract class for KeyBindings and MouseBindings. This class is thread-safe for all public operations.
- Key
Provides an abstraction for common keyboard operations and state. Used for processing keyboard input and raising keyboard events.
- KeyChangedEventArgs
Event args for when a Key is changed from one value to a new value (e.g. in HotKeyChanged)
- KeystrokeNavigatorEventArgs
Event arguments for the Terminal.Gui.Views.CollectionNavigatorBase.SearchStringChanged event.
- Mouse
Provides an abstraction for common mouse operations and state. Represents a mouse event, including position, button state, and other flags.
- MouseBindings
Provides a collection of MouseBinding objects bound to a combination of MouseFlags.
- MouseFlagsChangedEventArgs
Args for events that describe a change in MouseFlags
Structs
- CommandContext
Provides context for a Command invocation.
- InputBinding
A generic input binding used for programmatic command invocations or when a specific binding type is not needed.
- KeyBinding
Provides a collection of Command objects stored in KeyBindings.
- MouseBinding
Provides a collection of MouseFlags bound to Commands.
Interfaces
- ICommandContext
Describes the context in which a Command is being invoked. CommandContext<TBindingType> inherits from this interface. When a Command is invoked, a context object is passed to Command handlers as an ICommandContext reference.
- IInputBinding
Describes an input binding. Used to bind a set of Command objects to a specific input event.
Enums
- MouseFlags
Mouse flags reported in Mouse.