Vixen
02b45cc4
csharp
public readonly record struct KeyChord

A key and what is held with it.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ A key position, not a character, because that is what KeyEvent reports and what a keymap has to be written in — a binding stored as the letter somebody typed would move around the keyboard when they switched layout. The consequence is honest and worth knowing: Ctrl+Z is the key labelled Z on a US keyboard, which is where the undo shortcut is on a French one too, because that is how every application on the machine behaves.

Written as text, because a keymap is a file a person edits. Ctrl+Shift+S round-trips exactly, and an unparseable chord is None rather than an exception — a hand-edited keymap with one bad line loses that line rather than every binding in the file.

Fields and properties (5)

  • public InputKey Key

    The physical key, by its US-QWERTY legend.

  • public ModifierKeys Modifiers

    What is held down at the time.

  • public static KeyChord None

    No chord: what an unbound command has.

  • public static ModifierKeys Primary

    Which modifier this machine uses for an application's own shortcuts.

  • public bool IsBound

    Whether this is a chord at all.

Methods (11)

  • public KeyChord(InputKey Key, ModifierKeys Modifiers)

    A key and what is held with it.

  • public KeyChord ForPlatform()

    This chord with Control and Primary exchanged.

  • public KeyChord ForPlatform(ModifierKeys primary)
  • public string Describe()

    What a menu shows against the command.

  • public static void UsePlatformFormat(UiDocument? document = null)

    Makes every shortcut in the process read the way this machine writes them.

  • public static string MacWords(InputKey key, ModifierKeys modifiers)

    Writes a combination the way macOS has written them since 1984.

  • public static string MacFormat(InputKey key, ModifierKeys modifiers)
  • public string Save()

    What a keymap file writes.

  • public static bool TryParse(string? text, out KeyChord chord)

    Reads one back.

  • public static KeyChord Of(KeyEvent args)

    The chord a key event is.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (27)

  • BlockoutModeVixen.Editor.Blockout
  • BlockoutModeTestsVixen.Editor.Blockout.Tests
  • CommandDispatcherVixen.Editor.Ui
  • CommandPaletteSourceVixen.Editor.Ui
  • CommandTestsVixen.Editor.Ui.Tests
  • EditorApplicationVixen.Editor.App
  • EditorModeTestsVixen.Editor.App.Tests
  • EditorShellVixen.Editor.Ui
  • EditorShellTestsVixen.Editor.Ui.Tests
  • FoliageModeVixen.Editor.Terrain
  • FoliageModeTestsVixen.Editor.Terrain.Tests
  • KeyBindingsPanelTestsVixen.Editor.App.Tests
  • KeyBindingsViewVixen.Editor.Ui
  • KeyMapVixen.Editor.Ui
  • KeyMapPresetVixen.Editor.Ui
  • KeyMapPresetTestsVixen.Editor.Ui.Tests
  • MenuCompositionTestsVixen.Editor.Ui.Tests
  • MenuPresenterVixen.Editor.Ui
  • MenuTestsVixen.Editor.Ui.Tests
  • MilestoneE3TestsVixen.Editor.App.Tests
  • ModeTestsVixen.Editor.Ui.Tests
  • PlatformKeyTestsVixen.Editor.Ui.Tests
  • PluginContextVixen.Editor.Plugin
  • ScopeTestsVixen.Editor.Ui.Tests
  • TerrainModeVixen.Editor.Terrain
  • TerrainModeTestsVixen.Editor.Terrain.Tests
  • ToolbarPresenterVixen.Editor.Ui