Skip to content

Commit

Permalink
Clarify how multiple assignments to same keymap work
Browse files Browse the repository at this point in the history
  • Loading branch information
urob committed Feb 14, 2024
1 parent ae35804 commit 895e698
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/docs/customize/keybinds.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ New keybindings are created by binding a [command](commands.md) identifier to a
```csharp

Check failure on line 12 in docs/docs/customize/keybinds.md

View workflow job for this annotation

GitHub Actions / lint

Fenced code blocks should be surrounded by blank lines

docs/docs/customize/keybinds.md:12 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```csharp"] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md031.md
context.KeybindManager.SetKeybind("whim.core.cycle_layout_engine.next", new Keybind(KeyModifiers.LAlt, VIRTUAL_KEY.VK_SPACE));
```

Keybinds have a `Modifiers` and `Key` property. The available modifiers and keys can be found in the <xref:Whim.KeyModifiers> and <xref:Windows.Win32.UI.Input.KeyboardAndMouse.VIRTUAL_KEY> enums. Modifiers can be combined using the bitwise OR operator. For instance, the following creates a new <kbd>Alt</kbd> + <kbd>Shift</kbd> modifier, which can be used to create Keybinds:

```csharp
KeyModifiers AltShift = KeyModifiers.LAlt | KeyModifiers.LShift;
```

Check failure on line 20 in docs/docs/customize/keybinds.md

View workflow job for this annotation

GitHub Actions / lint

Fenced code blocks should be surrounded by blank lines

docs/docs/customize/keybinds.md:20 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md031.md
A number of common modifiers combinations is also accessible from the <xref:Whim.IKeybind> interface.

Check failure on line 21 in docs/docs/customize/keybinds.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

docs/docs/customize/keybinds.md:21:102 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md009.md

To treat key modifiers like `LWin` and `RWin` the same, see <xref:Whim.IKeybindManager.UnifyKeyModifiers>.

> [ !NOTE]
> Each _command_ can only be bound to a single keybind -- subsequent bindings to the same command will overwrite earlier ones. However, each _keybind_ can be assigned to multiple commands. If more than one command is triggered to a keymap, they will be triggered in the order of their assignment.
## Overwriting Keybinds

Each command can only be bound to a single keybind. Hence, any default binding can be overwritten by rebinding the corresponding command as described above.
Default bindings can be overwritten by simply rebinding the corresponding _command_ as described above.

> [!WARNING]
> When overriding keybinds for plugins, make sure to set the keybind **after** calling `context.PluginManager.AddPlugin(plugin)`.
Expand Down

0 comments on commit 895e698

Please sign in to comment.