IClipboardHandler
interface
Abstracts clipboard access so DocumentController remains platform-independent.
In Avalonia applications, AvaloniaClipboardHandler (from the Avalonia project) implements this.
| Method | Return Type | Description |
| GetTextAsync() | Task<string?> | Returns the current clipboard text, or null if empty. |
| SetTextAsync(string text) | Task | Places text onto the clipboard. |
| GetImageDataAsync() | Task<byte[]?> | Returns raw bitmap bytes if an image is on the clipboard, or null. |
KeyInfo
struct
A platform-agnostic description of a single key event. Construct it in your platform key handler
and pass it to DocumentController.OnKeyEvent().
| Member | Type | Description |
| KeyCode | KeyCode | The virtual key code (A–Z, D0–D9, F1–F24, arrows, etc.) |
| Shift | bool | Shift modifier held |
| Control | bool | Control modifier held |
| Alt | bool | Alt modifier held |
| Character | char? | Mapped printable character, or null if the key has no character (e.g., arrow keys) or if Control/Alt is held |
| HasCommandModifiers | bool | Control || Alt |
| HasModifiers | bool | Shift || Control || Alt |
| IsPrintableCharacter | bool | True when Character has a non-null printable value |
| AsShortcut() | Shortcut | Convert to a Shortcut for lookup in the ShortcutHandler |
// Avalonia OnKeyDown example
protected override async void OnKeyDown(KeyEventArgs e)
{
var key = new KeyInfo(
keyCode: e.Key.ToKeyCode(), // AvaloniaExtensions helper
shift: e.KeyModifiers.HasFlag(KeyModifiers.Shift),
control: e.KeyModifiers.HasFlag(KeyModifiers.Control),
alt: e.KeyModifiers.HasFlag(KeyModifiers.Alt)
);
bool consumed = await controller.OnKeyEvent(key);
if (consumed) e.Handled = true;
}
Shortcut
struct
A key combination descriptor. Use KeyInfo.AsShortcut() or construct directly.
| Member | Type | Description |
| BaseKey | KeyCode | The primary key |
| ControlKey | bool | Ctrl modifier required |
| ShiftKey | bool | Shift modifier required |
| AltKey | bool | Alt modifier required |
| Shortcut(KeyCode, bool shift, bool control, bool alt) | ctor | Construct explicitly |
ShortcutHandler
class
Maps Shortcut values to async actions and dispatches key events.
Access it via DocumentController.Shortcuts.
| Method | Description |
Map(Shortcut, Func<Task> action) | Register a custom shortcut. Overwrites any existing mapping for that combination. |
Execute(Shortcut) → Task<bool> | Invoke the action mapped to a shortcut. Returns true if a mapping was found. Called internally by OnKeyEvent(). |
// Add a custom Ctrl+Shift+H shortcut to insert a horizontal rule
controller.Shortcuts.Map(
new Shortcut(KeyCode.H, shift: true, control: true),
async () => { await controller.Insert("──────────"); }
);
// Remap Ctrl+B to apply a custom style instead of bold
controller.Shortcuts.Map(
new Shortcut(KeyCode.B, control: true),
async () => { await controller.ApplyStyle(myHeadingStyle); }
);
KeyMap (Static Utility)
class · static
Helpers for key classification and character mapping.
| Method | Return | Description |
IsPrintableCharacter(KeyCode code, bool shiftModifier = false) | bool | True if the key produces a printable character. |
GetCharacter(KeyCode, bool shift, bool capsLock = false) | char? | Returns the character for a key code + modifier combination, or null if not applicable. |
IsModifierKey(KeyCode key) | bool | True for Shift, Control, Alt, Win/Meta, CapsLock, etc. |
Built-in Default Shortcuts
| Shortcut | Action |
Ctrl+B | Toggle bold |
Ctrl+I | Toggle italic |
Ctrl+U | Toggle underline |
Ctrl+Z | Undo |
Ctrl+Y | Redo |
Ctrl+A | Select all |
Ctrl+C | Copy |
Ctrl+X | Cut |
Ctrl+V | Paste |
Tab (in list) | Increase list nesting level |
Shift+Tab (in list) | Decrease list nesting level |
Enter (on empty list item) | Exit list |
Backspace | Delete character before caret / delete selection |
Delete | Delete character after caret / delete selection |
Arrow keys | Navigate caret |
Shift+Arrow | Extend selection |
Home / End | Move to line start/end |
Ctrl+Home / Ctrl+End | Move to document start/end |