It should be possible to configure the terminal so that it doesn't send certain keystrokes as input to the terminal, and instead triggers certain actions. Examples of these actions could be copy/pasting text, opening a new tab, or changing the font size.
This spec describes a mechanism by which we could provide a common implementation of handling keyboard shortcuts like these. This common implementation could then be leveraged and extended by the UX implementation as to handle certain callbacks in the UX layer. For example, The TerminalCore doesn't have a concept of what a tab is, but the keymap abstraction could raise an event such that a WPF app could implement creating a new tab in its idiomatic way, and UWP could implement them in their own way.
When it's creating its platform-dependent terminal component, it can pass the `IKeyBindings` object to that component. The component will then be able to pass that object to the terminal instance.
When the terminal component calls `ITerminalInput.SendKeyEvent(uint vkey, KeyModifiers modifiers)`, the terminal will use `IKeyBindings.TryKeyChord` to see if there are any bound actions to that input. If there are, the `IKeyBindings` implementation will either handle the event by interacting with the `ITerminalInput`, or it'll invoke an event that's been registered by the frontend
```csharp
struct KeyChord
{
KeyModifiers modifiers;
int vkey;
}
interface IKeyBindings {
bool TryKeyChord(KeyChord kc);
}
```
Each frontend can implement the `IKeyBindings` interface however it so chooses.
The `ITerminalInput` interface will be extended with the following method:
```csharp
public interface ITerminalInput
{
...
void SetKeyBindings(IKeyBindings bindings);
...
}
```
This will set the `IKeyBindings` object that the `ITerminalInput` implementation will use to filter key events.
This method will be implemented by the `Terminal` object:
```csharp
partial class Terminal
{
public void ITerminalInput.SetKeyBindings(IKeyBindings bindings);
The Keybindings are global to the frontend, not local to the terminal. Copy/Paste events should also be delegates that get raised, and the frontend can then determine what to do with them. It'll probably query its active/focused Terminal Component, then Get the `ITerminalInput` from that component, and use that to CopyText / PasteText from the Terminal as needed.