Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(feat) Custom keyboard shortcuts: every key rebindable, conflicts caught before saving, edited marks and reset (#61) (#597)

Egor Khindikaynen6fca8d958b47
diff --git a/.agents/skills/nota-docs/SKILL.md b/.agents/skills/nota-docs/SKILL.md
index b648ce49..985f2821 100644
--- a/.agents/skills/nota-docs/SKILL.md
+++ b/.agents/skills/nota-docs/SKILL.md
@@ -92,8 +92,8 @@ args). `npm run shots -- <id-prefix> …` retakes them into `src/assets/shots/{d
- A scene breaks after an app refactor (renamed private method, control name) → fix the
harness; it reflects into `MainWindow` / `PreferencesWindow` privates on purpose.
- Shortcut changed → `npm run shortcuts` regenerates `reference/shortcuts` (EN + RU) from
- `PreferencesWindow.ShortcutGroups`; run the `nota-shortcuts` skill first so that list is
- right.
+ the key-action catalog and `ShortcutLayout` (specs/096); run the `nota-shortcuts` skill
+ first so they are right.
## 5. Verify and commit
diff --git a/.agents/skills/nota-shortcuts/SKILL.md b/.agents/skills/nota-shortcuts/SKILL.md
index 416d537b..da92b438 100644
--- a/.agents/skills/nota-shortcuts/SKILL.md
+++ b/.agents/skills/nota-shortcuts/SKILL.md
@@ -1,66 +1,58 @@
---
name: nota-shortcuts
-description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — the Shortcuts pane is a hand-maintained list and silently drifts from the handlers otherwise. Handles: finding every place bindings are defined, updating the on-screen list, and visually verifying it.
+description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — since specs/096 every key is a binding in the key-action catalog, so a new key must be declared there (not compared by hand in a handler) and a new gesture listed in ShortcutLayout. Handles: declaring the action, asking for it in the handler, the fixed rows, tests and visual verification.
user-invocable: true
---
# Keeping the Shortcuts screen honest
-Nota shows its keyboard/mouse shortcuts in **Preferences → Shortcuts**. That list is
-**hand-written**, not generated from the handlers — so every time the input handling
-changes, the screen must be updated by hand or it lies to the user. This skill is the
-checklist for doing that.
+Since specs/096 (#61) every keyboard shortcut is **rebindable** in Settings → Shortcuts.
+A key is no longer compared by hand in a handler and then described in a list: it is a
+**key action** with an id, a scope and a default, and the handler asks the user's bindings
+whether a press is that action. The Shortcuts page is built from the catalog, so an action
+can't be missing from it — but a key compared by hand, or a gesture nobody listed, still can.
**Trigger:** you touched anything that changes what a key or mouse gesture does — a new
-hotkey, a re-mapped key, a removed command, a changed computer-keyboard note layout, a new
-drag gesture. If your change added/removed/moved a binding, you are not done until the
-Shortcuts pane matches.
+hotkey, a re-mapped default, a removed command, the computer-keyboard note layout, a new
+drag gesture.
-## 1. The on-screen list (what to edit)
+## 1. Where things live
-`src/managed/Nota.App/PreferencesWindow.cs` → the static **`ShortcutGroups`** array (feeds
-`ShortcutsPane`). It's grouped: `TRANSPORT`, `ARRANGEMENT & EDITING`, `PIANO ROLL`,
-`PLAY NOTES (COMPUTER KEYBOARD)`, `MOUSE`. Each row is `(Key, Action)`; the `Key` string is
-split on spaces and each token becomes its own mono key-cap (`/` and `·` stay plain
-separators) — as long as every token is a key: no lower-case letters, or one of `Space`
-`Return` `Delete` `Tab` `Esc` (`IsKeyToken`). Anything else (`Drag note edge`, `Face
-buttons`) is a gesture and shows as plain text. The `Action` is a short sentence. Use `⌘` for Meta/Ctrl, `⇧`
-for Shift, `⌥` for Alt, and the arrow glyphs `← → ↑ ↓`. Keep actions imperative and terse
-(design language: sentence case, `·`/` / ` as separators).
-
-## 2. The source of truth (where bindings actually live)
-
-Read these and reconcile the list against them — do **not** trust the existing pane text:
-
-| Bindings | File |
+| What | File |
|---|---|
-| Transport (Space/Return), global editing (A, R, M, ⌘M, ⌘G/⌘⇧G, ⌘C/X/V, Delete, Tab, Esc) and the **computer-keyboard note map** (`KeyToPitch`) | `src/managed/Nota.App/MainWindow.Input.cs` |
-| Piano-roll note editing (arrows, ⇧ octave, ⌘A/⌘D, ⌘C/X/V, Delete, Esc) | `src/managed/Nota.App/PianoRollView.cs` (its `OnKeyDown`) |
-| Arrangement lane / clip gestures (double-click, drag) | `src/managed/Nota.App/ArrangementView*.cs` |
-| Device reorder drag | `src/managed/Nota.App/DeviceChainView.cs`, `DeviceCards/…` |
-
-`KeyToPitch` is the note layout: bare letters play notes, and `A` is **deliberately not** a
-note (it toggles automation mode) — so the "Play notes" rows must never list `A`. When that
-map changes, update the `PLAY NOTES` group (white vs. black keys, and the starting octave).
-
-## 3. Procedure
-
-1. List, from your own diff, every binding you added/changed/removed.
-2. Open the source-of-truth file(s) above and confirm the *current* behaviour of each key in
- the affected group — including ones you didn't touch, since the list may already be stale.
-3. Edit `ShortcutGroups` so every row matches. Add a row for a new binding, delete a row for a
- removed one, fix the key-cap or wording for a changed one. Put it in the right group.
-4. Build: `dotnet build src/managed/Nota.App -c Debug`.
-5. Visually verify (see [nota-ui-verify] memory): the pane can't be reached by a click in a
- headless run, so temporarily open it via an env-guarded hook in
- `MainWindow.OnDataContextChanged` (`new PreferencesWindow(new SettingsViewModel(settings),
- _vm).Show(this)`), and select the Shortcuts section (index 8 — count the sidebar entries, it moves as pages are added) — e.g. a temporary env read
- in front of the constructor's `Select(0)`. Screenshot with `screencapture -x -o -l<winid>`
- (get the id from the `winlist` swift helper), check the rows read correctly, then **revert
- the temp hooks** and rebuild.
-
-## 4. Don't forget
-
-- If the change is user-visible, it also wants a `CHANGELOG.md` entry under `## [Unreleased]`.
-- Keep the pane concise — it's a reference, not a manual. Group related keys onto one cap
- (`⌘C ⌘X ⌘V`) rather than three rows when the action is one idea.
+| Palette / menu commands and their default keys | `src/managed/Nota.Application/Palette/CommandCatalog.cs` (the gesture is the *default*) |
+| Every other key action (note map, nudges, transposes, browser, Modular, Session…), scopes, shared editing actions | `src/managed/Nota.Application/Input/KeyActionCatalog.cs` |
+| The user's keys, conflict rule, reset, persistence | `src/managed/Nota.Application/Input/KeyBindings.cs` |
+| What the page lists, in which group; the **fixed rows** (mouse, trackpad, gamepad, list and typing keys) | `src/managed/Nota.Application/Input/ShortcutLayout.cs` |
+| Asking in a handler: `Keys.Is(e, "roll.transposeUp")`, `Keys.Which(e, …)` | `src/managed/Nota.App/Input/Keys.cs` |
+| The editor (capture, conflicts, reset) | `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs` |
+
+Scopes (research R3 in `specs/096-custom-shortcuts`): Global, Arrangement and Notes are
+window-wide and conflict with each other; Session, PianoRoll, AudioEditor, Devices, Browser and
+Modular are focus scopes that win while they have the keyboard. A menu chord reaches every
+scope. Copy / Cut / Paste / Duplicate / Delete / Select all / Cancel (`edit.*`) are **shared**
+— one binding read by every view, never a per-view action.
+
+## 2. Procedure
+
+1. **New key**: add a `KeyAction` (an existing command: give `CommandCatalog` its gesture; a
+ view key: `Add(...)` in `KeyActionCatalog` with a literal `Loc.T("keys.…")` title and the
+ right scope). Paired keys are one action per direction.
+2. In the handler, ask `Keys.Is(e, id)` / `Keys.Which(e, ids)` — never `e.Key == Key.X`. Keep
+ the handler's focus gates and order. List-navigation and typing keys (arrows in a list,
+ Return / Esc / Tab in a text box) stay fixed and are compared directly.
+3. **New gesture or fixed key**: add an `F(key, text)` row to its group in `ShortcutLayout`.
+4. Default keys must not collide (rule R3) — `KeyBindingTests` lists the pairs allowed on
+ purpose; a new one fails until it is added there with its reason.
+5. Build and run `dotnet run --project tests/Nota.SmokeTest -c Release -- --shortcuts` and
+ `-- --palette` (every action is laid out once), and `-- --localization` (new strings).
+6. Visually verify with the headless harness (memory: nota-ui-verify) —
+ `PreferencesWindow.ShowPage("Shortcuts")`, a filter, and `StartCapture` / `Propose` by
+ reflection for the editor states.
+
+## 3. Don't forget
+
+- User-visible → `CHANGELOG.md` `[Unreleased]`, and the user docs: `npm run shortcuts` in
+ nota-docs regenerates `reference/shortcuts` from the layout.
+- Tooltips naming a key: `Keys.SetTip(control, text, id)` (the default glyph in the text is
+ swapped for the user's key). Context-menu hints: `MenuKit.Bound(id)`.
diff --git a/.claude/skills/nota-docs/SKILL.md b/.claude/skills/nota-docs/SKILL.md
index b648ce49..985f2821 100644
--- a/.claude/skills/nota-docs/SKILL.md
+++ b/.claude/skills/nota-docs/SKILL.md
@@ -92,8 +92,8 @@ args). `npm run shots -- <id-prefix> …` retakes them into `src/assets/shots/{d
- A scene breaks after an app refactor (renamed private method, control name) → fix the
harness; it reflects into `MainWindow` / `PreferencesWindow` privates on purpose.
- Shortcut changed → `npm run shortcuts` regenerates `reference/shortcuts` (EN + RU) from
- `PreferencesWindow.ShortcutGroups`; run the `nota-shortcuts` skill first so that list is
- right.
+ the key-action catalog and `ShortcutLayout` (specs/096); run the `nota-shortcuts` skill
+ first so they are right.
## 5. Verify and commit
diff --git a/.claude/skills/nota-shortcuts/SKILL.md b/.claude/skills/nota-shortcuts/SKILL.md
index 416d537b..da92b438 100644
--- a/.claude/skills/nota-shortcuts/SKILL.md
+++ b/.claude/skills/nota-shortcuts/SKILL.md
@@ -1,66 +1,58 @@
---
name: nota-shortcuts
-description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — the Shortcuts pane is a hand-maintained list and silently drifts from the handlers otherwise. Handles: finding every place bindings are defined, updating the on-screen list, and visually verifying it.
+description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — since specs/096 every key is a binding in the key-action catalog, so a new key must be declared there (not compared by hand in a handler) and a new gesture listed in ShortcutLayout. Handles: declaring the action, asking for it in the handler, the fixed rows, tests and visual verification.
user-invocable: true
---
# Keeping the Shortcuts screen honest
-Nota shows its keyboard/mouse shortcuts in **Preferences → Shortcuts**. That list is
-**hand-written**, not generated from the handlers — so every time the input handling
-changes, the screen must be updated by hand or it lies to the user. This skill is the
-checklist for doing that.
+Since specs/096 (#61) every keyboard shortcut is **rebindable** in Settings → Shortcuts.
+A key is no longer compared by hand in a handler and then described in a list: it is a
+**key action** with an id, a scope and a default, and the handler asks the user's bindings
+whether a press is that action. The Shortcuts page is built from the catalog, so an action
+can't be missing from it — but a key compared by hand, or a gesture nobody listed, still can.
**Trigger:** you touched anything that changes what a key or mouse gesture does — a new
-hotkey, a re-mapped key, a removed command, a changed computer-keyboard note layout, a new
-drag gesture. If your change added/removed/moved a binding, you are not done until the
-Shortcuts pane matches.
+hotkey, a re-mapped default, a removed command, the computer-keyboard note layout, a new
+drag gesture.
-## 1. The on-screen list (what to edit)
+## 1. Where things live
-`src/managed/Nota.App/PreferencesWindow.cs` → the static **`ShortcutGroups`** array (feeds
-`ShortcutsPane`). It's grouped: `TRANSPORT`, `ARRANGEMENT & EDITING`, `PIANO ROLL`,
-`PLAY NOTES (COMPUTER KEYBOARD)`, `MOUSE`. Each row is `(Key, Action)`; the `Key` string is
-split on spaces and each token becomes its own mono key-cap (`/` and `·` stay plain
-separators) — as long as every token is a key: no lower-case letters, or one of `Space`
-`Return` `Delete` `Tab` `Esc` (`IsKeyToken`). Anything else (`Drag note edge`, `Face
-buttons`) is a gesture and shows as plain text. The `Action` is a short sentence. Use `⌘` for Meta/Ctrl, `⇧`
-for Shift, `⌥` for Alt, and the arrow glyphs `← → ↑ ↓`. Keep actions imperative and terse
-(design language: sentence case, `·`/` / ` as separators).
-
-## 2. The source of truth (where bindings actually live)
-
-Read these and reconcile the list against them — do **not** trust the existing pane text:
-
-| Bindings | File |
+| What | File |
|---|---|
-| Transport (Space/Return), global editing (A, R, M, ⌘M, ⌘G/⌘⇧G, ⌘C/X/V, Delete, Tab, Esc) and the **computer-keyboard note map** (`KeyToPitch`) | `src/managed/Nota.App/MainWindow.Input.cs` |
-| Piano-roll note editing (arrows, ⇧ octave, ⌘A/⌘D, ⌘C/X/V, Delete, Esc) | `src/managed/Nota.App/PianoRollView.cs` (its `OnKeyDown`) |
-| Arrangement lane / clip gestures (double-click, drag) | `src/managed/Nota.App/ArrangementView*.cs` |
-| Device reorder drag | `src/managed/Nota.App/DeviceChainView.cs`, `DeviceCards/…` |
-
-`KeyToPitch` is the note layout: bare letters play notes, and `A` is **deliberately not** a
-note (it toggles automation mode) — so the "Play notes" rows must never list `A`. When that
-map changes, update the `PLAY NOTES` group (white vs. black keys, and the starting octave).
-
-## 3. Procedure
-
-1. List, from your own diff, every binding you added/changed/removed.
-2. Open the source-of-truth file(s) above and confirm the *current* behaviour of each key in
- the affected group — including ones you didn't touch, since the list may already be stale.
-3. Edit `ShortcutGroups` so every row matches. Add a row for a new binding, delete a row for a
- removed one, fix the key-cap or wording for a changed one. Put it in the right group.
-4. Build: `dotnet build src/managed/Nota.App -c Debug`.
-5. Visually verify (see [nota-ui-verify] memory): the pane can't be reached by a click in a
- headless run, so temporarily open it via an env-guarded hook in
- `MainWindow.OnDataContextChanged` (`new PreferencesWindow(new SettingsViewModel(settings),
- _vm).Show(this)`), and select the Shortcuts section (index 8 — count the sidebar entries, it moves as pages are added) — e.g. a temporary env read
- in front of the constructor's `Select(0)`. Screenshot with `screencapture -x -o -l<winid>`
- (get the id from the `winlist` swift helper), check the rows read correctly, then **revert
- the temp hooks** and rebuild.
-
-## 4. Don't forget
-
-- If the change is user-visible, it also wants a `CHANGELOG.md` entry under `## [Unreleased]`.
-- Keep the pane concise — it's a reference, not a manual. Group related keys onto one cap
- (`⌘C ⌘X ⌘V`) rather than three rows when the action is one idea.
+| Palette / menu commands and their default keys | `src/managed/Nota.Application/Palette/CommandCatalog.cs` (the gesture is the *default*) |
+| Every other key action (note map, nudges, transposes, browser, Modular, Session…), scopes, shared editing actions | `src/managed/Nota.Application/Input/KeyActionCatalog.cs` |
+| The user's keys, conflict rule, reset, persistence | `src/managed/Nota.Application/Input/KeyBindings.cs` |
+| What the page lists, in which group; the **fixed rows** (mouse, trackpad, gamepad, list and typing keys) | `src/managed/Nota.Application/Input/ShortcutLayout.cs` |
+| Asking in a handler: `Keys.Is(e, "roll.transposeUp")`, `Keys.Which(e, …)` | `src/managed/Nota.App/Input/Keys.cs` |
+| The editor (capture, conflicts, reset) | `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs` |
+
+Scopes (research R3 in `specs/096-custom-shortcuts`): Global, Arrangement and Notes are
+window-wide and conflict with each other; Session, PianoRoll, AudioEditor, Devices, Browser and
+Modular are focus scopes that win while they have the keyboard. A menu chord reaches every
+scope. Copy / Cut / Paste / Duplicate / Delete / Select all / Cancel (`edit.*`) are **shared**
+— one binding read by every view, never a per-view action.
+
+## 2. Procedure
+
+1. **New key**: add a `KeyAction` (an existing command: give `CommandCatalog` its gesture; a
+ view key: `Add(...)` in `KeyActionCatalog` with a literal `Loc.T("keys.…")` title and the
+ right scope). Paired keys are one action per direction.
+2. In the handler, ask `Keys.Is(e, id)` / `Keys.Which(e, ids)` — never `e.Key == Key.X`. Keep
+ the handler's focus gates and order. List-navigation and typing keys (arrows in a list,
+ Return / Esc / Tab in a text box) stay fixed and are compared directly.
+3. **New gesture or fixed key**: add an `F(key, text)` row to its group in `ShortcutLayout`.
+4. Default keys must not collide (rule R3) — `KeyBindingTests` lists the pairs allowed on
+ purpose; a new one fails until it is added there with its reason.
+5. Build and run `dotnet run --project tests/Nota.SmokeTest -c Release -- --shortcuts` and
+ `-- --palette` (every action is laid out once), and `-- --localization` (new strings).
+6. Visually verify with the headless harness (memory: nota-ui-verify) —
+ `PreferencesWindow.ShowPage("Shortcuts")`, a filter, and `StartCapture` / `Propose` by
+ reflection for the editor states.
+
+## 3. Don't forget
+
+- User-visible → `CHANGELOG.md` `[Unreleased]`, and the user docs: `npm run shortcuts` in
+ nota-docs regenerates `reference/shortcuts` from the layout.
+- Tooltips naming a key: `Keys.SetTip(control, text, id)` (the default glyph in the text is
+ swapped for the user's key). Context-menu hints: `MenuKit.Bound(id)`.
diff --git a/.cursor/skills/nota-docs/SKILL.md b/.cursor/skills/nota-docs/SKILL.md
index b648ce49..985f2821 100644
--- a/.cursor/skills/nota-docs/SKILL.md
+++ b/.cursor/skills/nota-docs/SKILL.md
@@ -92,8 +92,8 @@ args). `npm run shots -- <id-prefix> …` retakes them into `src/assets/shots/{d
- A scene breaks after an app refactor (renamed private method, control name) → fix the
harness; it reflects into `MainWindow` / `PreferencesWindow` privates on purpose.
- Shortcut changed → `npm run shortcuts` regenerates `reference/shortcuts` (EN + RU) from
- `PreferencesWindow.ShortcutGroups`; run the `nota-shortcuts` skill first so that list is
- right.
+ the key-action catalog and `ShortcutLayout` (specs/096); run the `nota-shortcuts` skill
+ first so they are right.
## 5. Verify and commit
diff --git a/.cursor/skills/nota-shortcuts/SKILL.md b/.cursor/skills/nota-shortcuts/SKILL.md
index 416d537b..da92b438 100644
--- a/.cursor/skills/nota-shortcuts/SKILL.md
+++ b/.cursor/skills/nota-shortcuts/SKILL.md
@@ -1,66 +1,58 @@
---
name: nota-shortcuts
-description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — the Shortcuts pane is a hand-maintained list and silently drifts from the handlers otherwise. Handles: finding every place bindings are defined, updating the on-screen list, and visually verifying it.
+description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — since specs/096 every key is a binding in the key-action catalog, so a new key must be declared there (not compared by hand in a handler) and a new gesture listed in ShortcutLayout. Handles: declaring the action, asking for it in the handler, the fixed rows, tests and visual verification.
user-invocable: true
---
# Keeping the Shortcuts screen honest
-Nota shows its keyboard/mouse shortcuts in **Preferences → Shortcuts**. That list is
-**hand-written**, not generated from the handlers — so every time the input handling
-changes, the screen must be updated by hand or it lies to the user. This skill is the
-checklist for doing that.
+Since specs/096 (#61) every keyboard shortcut is **rebindable** in Settings → Shortcuts.
+A key is no longer compared by hand in a handler and then described in a list: it is a
+**key action** with an id, a scope and a default, and the handler asks the user's bindings
+whether a press is that action. The Shortcuts page is built from the catalog, so an action
+can't be missing from it — but a key compared by hand, or a gesture nobody listed, still can.
**Trigger:** you touched anything that changes what a key or mouse gesture does — a new
-hotkey, a re-mapped key, a removed command, a changed computer-keyboard note layout, a new
-drag gesture. If your change added/removed/moved a binding, you are not done until the
-Shortcuts pane matches.
+hotkey, a re-mapped default, a removed command, the computer-keyboard note layout, a new
+drag gesture.
-## 1. The on-screen list (what to edit)
+## 1. Where things live
-`src/managed/Nota.App/PreferencesWindow.cs` → the static **`ShortcutGroups`** array (feeds
-`ShortcutsPane`). It's grouped: `TRANSPORT`, `ARRANGEMENT & EDITING`, `PIANO ROLL`,
-`PLAY NOTES (COMPUTER KEYBOARD)`, `MOUSE`. Each row is `(Key, Action)`; the `Key` string is
-split on spaces and each token becomes its own mono key-cap (`/` and `·` stay plain
-separators) — as long as every token is a key: no lower-case letters, or one of `Space`
-`Return` `Delete` `Tab` `Esc` (`IsKeyToken`). Anything else (`Drag note edge`, `Face
-buttons`) is a gesture and shows as plain text. The `Action` is a short sentence. Use `⌘` for Meta/Ctrl, `⇧`
-for Shift, `⌥` for Alt, and the arrow glyphs `← → ↑ ↓`. Keep actions imperative and terse
-(design language: sentence case, `·`/` / ` as separators).
-
-## 2. The source of truth (where bindings actually live)
-
-Read these and reconcile the list against them — do **not** trust the existing pane text:
-
-| Bindings | File |
+| What | File |
|---|---|
-| Transport (Space/Return), global editing (A, R, M, ⌘M, ⌘G/⌘⇧G, ⌘C/X/V, Delete, Tab, Esc) and the **computer-keyboard note map** (`KeyToPitch`) | `src/managed/Nota.App/MainWindow.Input.cs` |
-| Piano-roll note editing (arrows, ⇧ octave, ⌘A/⌘D, ⌘C/X/V, Delete, Esc) | `src/managed/Nota.App/PianoRollView.cs` (its `OnKeyDown`) |
-| Arrangement lane / clip gestures (double-click, drag) | `src/managed/Nota.App/ArrangementView*.cs` |
-| Device reorder drag | `src/managed/Nota.App/DeviceChainView.cs`, `DeviceCards/…` |
-
-`KeyToPitch` is the note layout: bare letters play notes, and `A` is **deliberately not** a
-note (it toggles automation mode) — so the "Play notes" rows must never list `A`. When that
-map changes, update the `PLAY NOTES` group (white vs. black keys, and the starting octave).
-
-## 3. Procedure
-
-1. List, from your own diff, every binding you added/changed/removed.
-2. Open the source-of-truth file(s) above and confirm the *current* behaviour of each key in
- the affected group — including ones you didn't touch, since the list may already be stale.
-3. Edit `ShortcutGroups` so every row matches. Add a row for a new binding, delete a row for a
- removed one, fix the key-cap or wording for a changed one. Put it in the right group.
-4. Build: `dotnet build src/managed/Nota.App -c Debug`.
-5. Visually verify (see [nota-ui-verify] memory): the pane can't be reached by a click in a
- headless run, so temporarily open it via an env-guarded hook in
- `MainWindow.OnDataContextChanged` (`new PreferencesWindow(new SettingsViewModel(settings),
- _vm).Show(this)`), and select the Shortcuts section (index 8 — count the sidebar entries, it moves as pages are added) — e.g. a temporary env read
- in front of the constructor's `Select(0)`. Screenshot with `screencapture -x -o -l<winid>`
- (get the id from the `winlist` swift helper), check the rows read correctly, then **revert
- the temp hooks** and rebuild.
-
-## 4. Don't forget
-
-- If the change is user-visible, it also wants a `CHANGELOG.md` entry under `## [Unreleased]`.
-- Keep the pane concise — it's a reference, not a manual. Group related keys onto one cap
- (`⌘C ⌘X ⌘V`) rather than three rows when the action is one idea.
+| Palette / menu commands and their default keys | `src/managed/Nota.Application/Palette/CommandCatalog.cs` (the gesture is the *default*) |
+| Every other key action (note map, nudges, transposes, browser, Modular, Session…), scopes, shared editing actions | `src/managed/Nota.Application/Input/KeyActionCatalog.cs` |
+| The user's keys, conflict rule, reset, persistence | `src/managed/Nota.Application/Input/KeyBindings.cs` |
+| What the page lists, in which group; the **fixed rows** (mouse, trackpad, gamepad, list and typing keys) | `src/managed/Nota.Application/Input/ShortcutLayout.cs` |
+| Asking in a handler: `Keys.Is(e, "roll.transposeUp")`, `Keys.Which(e, …)` | `src/managed/Nota.App/Input/Keys.cs` |
+| The editor (capture, conflicts, reset) | `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs` |
+
+Scopes (research R3 in `specs/096-custom-shortcuts`): Global, Arrangement and Notes are
+window-wide and conflict with each other; Session, PianoRoll, AudioEditor, Devices, Browser and
+Modular are focus scopes that win while they have the keyboard. A menu chord reaches every
+scope. Copy / Cut / Paste / Duplicate / Delete / Select all / Cancel (`edit.*`) are **shared**
+— one binding read by every view, never a per-view action.
+
+## 2. Procedure
+
+1. **New key**: add a `KeyAction` (an existing command: give `CommandCatalog` its gesture; a
+ view key: `Add(...)` in `KeyActionCatalog` with a literal `Loc.T("keys.…")` title and the
+ right scope). Paired keys are one action per direction.
+2. In the handler, ask `Keys.Is(e, id)` / `Keys.Which(e, ids)` — never `e.Key == Key.X`. Keep
+ the handler's focus gates and order. List-navigation and typing keys (arrows in a list,
+ Return / Esc / Tab in a text box) stay fixed and are compared directly.
+3. **New gesture or fixed key**: add an `F(key, text)` row to its group in `ShortcutLayout`.
+4. Default keys must not collide (rule R3) — `KeyBindingTests` lists the pairs allowed on
+ purpose; a new one fails until it is added there with its reason.
+5. Build and run `dotnet run --project tests/Nota.SmokeTest -c Release -- --shortcuts` and
+ `-- --palette` (every action is laid out once), and `-- --localization` (new strings).
+6. Visually verify with the headless harness (memory: nota-ui-verify) —
+ `PreferencesWindow.ShowPage("Shortcuts")`, a filter, and `StartCapture` / `Propose` by
+ reflection for the editor states.
+
+## 3. Don't forget
+
+- User-visible → `CHANGELOG.md` `[Unreleased]`, and the user docs: `npm run shortcuts` in
+ nota-docs regenerates `reference/shortcuts` from the layout.
+- Tooltips naming a key: `Keys.SetTip(control, text, id)` (the default glyph in the text is
+ swapped for the user's key). Context-menu hints: `MenuKit.Bound(id)`.
diff --git a/.gemini/skills/nota-docs/SKILL.md b/.gemini/skills/nota-docs/SKILL.md
index b648ce49..985f2821 100644
--- a/.gemini/skills/nota-docs/SKILL.md
+++ b/.gemini/skills/nota-docs/SKILL.md
@@ -92,8 +92,8 @@ args). `npm run shots -- <id-prefix> …` retakes them into `src/assets/shots/{d
- A scene breaks after an app refactor (renamed private method, control name) → fix the
harness; it reflects into `MainWindow` / `PreferencesWindow` privates on purpose.
- Shortcut changed → `npm run shortcuts` regenerates `reference/shortcuts` (EN + RU) from
- `PreferencesWindow.ShortcutGroups`; run the `nota-shortcuts` skill first so that list is
- right.
+ the key-action catalog and `ShortcutLayout` (specs/096); run the `nota-shortcuts` skill
+ first so they are right.
## 5. Verify and commit
diff --git a/.gemini/skills/nota-shortcuts/SKILL.md b/.gemini/skills/nota-shortcuts/SKILL.md
index 416d537b..da92b438 100644
--- a/.gemini/skills/nota-shortcuts/SKILL.md
+++ b/.gemini/skills/nota-shortcuts/SKILL.md
@@ -1,66 +1,58 @@
---
name: nota-shortcuts
-description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — the Shortcuts pane is a hand-maintained list and silently drifts from the handlers otherwise. Handles: finding every place bindings are defined, updating the on-screen list, and visually verifying it.
+description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — since specs/096 every key is a binding in the key-action catalog, so a new key must be declared there (not compared by hand in a handler) and a new gesture listed in ShortcutLayout. Handles: declaring the action, asking for it in the handler, the fixed rows, tests and visual verification.
user-invocable: true
---
# Keeping the Shortcuts screen honest
-Nota shows its keyboard/mouse shortcuts in **Preferences → Shortcuts**. That list is
-**hand-written**, not generated from the handlers — so every time the input handling
-changes, the screen must be updated by hand or it lies to the user. This skill is the
-checklist for doing that.
+Since specs/096 (#61) every keyboard shortcut is **rebindable** in Settings → Shortcuts.
+A key is no longer compared by hand in a handler and then described in a list: it is a
+**key action** with an id, a scope and a default, and the handler asks the user's bindings
+whether a press is that action. The Shortcuts page is built from the catalog, so an action
+can't be missing from it — but a key compared by hand, or a gesture nobody listed, still can.
**Trigger:** you touched anything that changes what a key or mouse gesture does — a new
-hotkey, a re-mapped key, a removed command, a changed computer-keyboard note layout, a new
-drag gesture. If your change added/removed/moved a binding, you are not done until the
-Shortcuts pane matches.
+hotkey, a re-mapped default, a removed command, the computer-keyboard note layout, a new
+drag gesture.
-## 1. The on-screen list (what to edit)
+## 1. Where things live
-`src/managed/Nota.App/PreferencesWindow.cs` → the static **`ShortcutGroups`** array (feeds
-`ShortcutsPane`). It's grouped: `TRANSPORT`, `ARRANGEMENT & EDITING`, `PIANO ROLL`,
-`PLAY NOTES (COMPUTER KEYBOARD)`, `MOUSE`. Each row is `(Key, Action)`; the `Key` string is
-split on spaces and each token becomes its own mono key-cap (`/` and `·` stay plain
-separators) — as long as every token is a key: no lower-case letters, or one of `Space`
-`Return` `Delete` `Tab` `Esc` (`IsKeyToken`). Anything else (`Drag note edge`, `Face
-buttons`) is a gesture and shows as plain text. The `Action` is a short sentence. Use `⌘` for Meta/Ctrl, `⇧`
-for Shift, `⌥` for Alt, and the arrow glyphs `← → ↑ ↓`. Keep actions imperative and terse
-(design language: sentence case, `·`/` / ` as separators).
-
-## 2. The source of truth (where bindings actually live)
-
-Read these and reconcile the list against them — do **not** trust the existing pane text:
-
-| Bindings | File |
+| What | File |
|---|---|
-| Transport (Space/Return), global editing (A, R, M, ⌘M, ⌘G/⌘⇧G, ⌘C/X/V, Delete, Tab, Esc) and the **computer-keyboard note map** (`KeyToPitch`) | `src/managed/Nota.App/MainWindow.Input.cs` |
-| Piano-roll note editing (arrows, ⇧ octave, ⌘A/⌘D, ⌘C/X/V, Delete, Esc) | `src/managed/Nota.App/PianoRollView.cs` (its `OnKeyDown`) |
-| Arrangement lane / clip gestures (double-click, drag) | `src/managed/Nota.App/ArrangementView*.cs` |
-| Device reorder drag | `src/managed/Nota.App/DeviceChainView.cs`, `DeviceCards/…` |
-
-`KeyToPitch` is the note layout: bare letters play notes, and `A` is **deliberately not** a
-note (it toggles automation mode) — so the "Play notes" rows must never list `A`. When that
-map changes, update the `PLAY NOTES` group (white vs. black keys, and the starting octave).
-
-## 3. Procedure
-
-1. List, from your own diff, every binding you added/changed/removed.
-2. Open the source-of-truth file(s) above and confirm the *current* behaviour of each key in
- the affected group — including ones you didn't touch, since the list may already be stale.
-3. Edit `ShortcutGroups` so every row matches. Add a row for a new binding, delete a row for a
- removed one, fix the key-cap or wording for a changed one. Put it in the right group.
-4. Build: `dotnet build src/managed/Nota.App -c Debug`.
-5. Visually verify (see [nota-ui-verify] memory): the pane can't be reached by a click in a
- headless run, so temporarily open it via an env-guarded hook in
- `MainWindow.OnDataContextChanged` (`new PreferencesWindow(new SettingsViewModel(settings),
- _vm).Show(this)`), and select the Shortcuts section (index 8 — count the sidebar entries, it moves as pages are added) — e.g. a temporary env read
- in front of the constructor's `Select(0)`. Screenshot with `screencapture -x -o -l<winid>`
- (get the id from the `winlist` swift helper), check the rows read correctly, then **revert
- the temp hooks** and rebuild.
-
-## 4. Don't forget
-
-- If the change is user-visible, it also wants a `CHANGELOG.md` entry under `## [Unreleased]`.
-- Keep the pane concise — it's a reference, not a manual. Group related keys onto one cap
- (`⌘C ⌘X ⌘V`) rather than three rows when the action is one idea.
+| Palette / menu commands and their default keys | `src/managed/Nota.Application/Palette/CommandCatalog.cs` (the gesture is the *default*) |
+| Every other key action (note map, nudges, transposes, browser, Modular, Session…), scopes, shared editing actions | `src/managed/Nota.Application/Input/KeyActionCatalog.cs` |
+| The user's keys, conflict rule, reset, persistence | `src/managed/Nota.Application/Input/KeyBindings.cs` |
+| What the page lists, in which group; the **fixed rows** (mouse, trackpad, gamepad, list and typing keys) | `src/managed/Nota.Application/Input/ShortcutLayout.cs` |
+| Asking in a handler: `Keys.Is(e, "roll.transposeUp")`, `Keys.Which(e, …)` | `src/managed/Nota.App/Input/Keys.cs` |
+| The editor (capture, conflicts, reset) | `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs` |
+
+Scopes (research R3 in `specs/096-custom-shortcuts`): Global, Arrangement and Notes are
+window-wide and conflict with each other; Session, PianoRoll, AudioEditor, Devices, Browser and
+Modular are focus scopes that win while they have the keyboard. A menu chord reaches every
+scope. Copy / Cut / Paste / Duplicate / Delete / Select all / Cancel (`edit.*`) are **shared**
+— one binding read by every view, never a per-view action.
+
+## 2. Procedure
+
+1. **New key**: add a `KeyAction` (an existing command: give `CommandCatalog` its gesture; a
+ view key: `Add(...)` in `KeyActionCatalog` with a literal `Loc.T("keys.…")` title and the
+ right scope). Paired keys are one action per direction.
+2. In the handler, ask `Keys.Is(e, id)` / `Keys.Which(e, ids)` — never `e.Key == Key.X`. Keep
+ the handler's focus gates and order. List-navigation and typing keys (arrows in a list,
+ Return / Esc / Tab in a text box) stay fixed and are compared directly.
+3. **New gesture or fixed key**: add an `F(key, text)` row to its group in `ShortcutLayout`.
+4. Default keys must not collide (rule R3) — `KeyBindingTests` lists the pairs allowed on
+ purpose; a new one fails until it is added there with its reason.
+5. Build and run `dotnet run --project tests/Nota.SmokeTest -c Release -- --shortcuts` and
+ `-- --palette` (every action is laid out once), and `-- --localization` (new strings).
+6. Visually verify with the headless harness (memory: nota-ui-verify) —
+ `PreferencesWindow.ShowPage("Shortcuts")`, a filter, and `StartCapture` / `Propose` by
+ reflection for the editor states.
+
+## 3. Don't forget
+
+- User-visible → `CHANGELOG.md` `[Unreleased]`, and the user docs: `npm run shortcuts` in
+ nota-docs regenerates `reference/shortcuts` from the layout.
+- Tooltips naming a key: `Keys.SetTip(control, text, id)` (the default glyph in the text is
+ swapped for the user's key). Context-menu hints: `MenuKit.Bound(id)`.
diff --git a/.github/skills/nota-docs/SKILL.md b/.github/skills/nota-docs/SKILL.md
index b648ce49..985f2821 100644
--- a/.github/skills/nota-docs/SKILL.md
+++ b/.github/skills/nota-docs/SKILL.md
@@ -92,8 +92,8 @@ args). `npm run shots -- <id-prefix> …` retakes them into `src/assets/shots/{d
- A scene breaks after an app refactor (renamed private method, control name) → fix the
harness; it reflects into `MainWindow` / `PreferencesWindow` privates on purpose.
- Shortcut changed → `npm run shortcuts` regenerates `reference/shortcuts` (EN + RU) from
- `PreferencesWindow.ShortcutGroups`; run the `nota-shortcuts` skill first so that list is
- right.
+ the key-action catalog and `ShortcutLayout` (specs/096); run the `nota-shortcuts` skill
+ first so they are right.
## 5. Verify and commit
diff --git a/.github/skills/nota-shortcuts/SKILL.md b/.github/skills/nota-shortcuts/SKILL.md
index 416d537b..da92b438 100644
--- a/.github/skills/nota-shortcuts/SKILL.md
+++ b/.github/skills/nota-shortcuts/SKILL.md
@@ -1,66 +1,58 @@
---
name: nota-shortcuts
-description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — the Shortcuts pane is a hand-maintained list and silently drifts from the handlers otherwise. Handles: finding every place bindings are defined, updating the on-screen list, and visually verifying it.
+description: Keep the Preferences → Shortcuts screen in sync with the app's real keyboard/mouse bindings. Run this WHENEVER you add, remove, or change a keyboard shortcut or mouse gesture (transport keys, editing commands, piano-roll keys, the computer-keyboard note map, device drag, etc.) — since specs/096 every key is a binding in the key-action catalog, so a new key must be declared there (not compared by hand in a handler) and a new gesture listed in ShortcutLayout. Handles: declaring the action, asking for it in the handler, the fixed rows, tests and visual verification.
user-invocable: true
---
# Keeping the Shortcuts screen honest
-Nota shows its keyboard/mouse shortcuts in **Preferences → Shortcuts**. That list is
-**hand-written**, not generated from the handlers — so every time the input handling
-changes, the screen must be updated by hand or it lies to the user. This skill is the
-checklist for doing that.
+Since specs/096 (#61) every keyboard shortcut is **rebindable** in Settings → Shortcuts.
+A key is no longer compared by hand in a handler and then described in a list: it is a
+**key action** with an id, a scope and a default, and the handler asks the user's bindings
+whether a press is that action. The Shortcuts page is built from the catalog, so an action
+can't be missing from it — but a key compared by hand, or a gesture nobody listed, still can.
**Trigger:** you touched anything that changes what a key or mouse gesture does — a new
-hotkey, a re-mapped key, a removed command, a changed computer-keyboard note layout, a new
-drag gesture. If your change added/removed/moved a binding, you are not done until the
-Shortcuts pane matches.
+hotkey, a re-mapped default, a removed command, the computer-keyboard note layout, a new
+drag gesture.
-## 1. The on-screen list (what to edit)
+## 1. Where things live
-`src/managed/Nota.App/PreferencesWindow.cs` → the static **`ShortcutGroups`** array (feeds
-`ShortcutsPane`). It's grouped: `TRANSPORT`, `ARRANGEMENT & EDITING`, `PIANO ROLL`,
-`PLAY NOTES (COMPUTER KEYBOARD)`, `MOUSE`. Each row is `(Key, Action)`; the `Key` string is
-split on spaces and each token becomes its own mono key-cap (`/` and `·` stay plain
-separators) — as long as every token is a key: no lower-case letters, or one of `Space`
-`Return` `Delete` `Tab` `Esc` (`IsKeyToken`). Anything else (`Drag note edge`, `Face
-buttons`) is a gesture and shows as plain text. The `Action` is a short sentence. Use `⌘` for Meta/Ctrl, `⇧`
-for Shift, `⌥` for Alt, and the arrow glyphs `← → ↑ ↓`. Keep actions imperative and terse
-(design language: sentence case, `·`/` / ` as separators).
-
-## 2. The source of truth (where bindings actually live)
-
-Read these and reconcile the list against them — do **not** trust the existing pane text:
-
-| Bindings | File |
+| What | File |
|---|---|
-| Transport (Space/Return), global editing (A, R, M, ⌘M, ⌘G/⌘⇧G, ⌘C/X/V, Delete, Tab, Esc) and the **computer-keyboard note map** (`KeyToPitch`) | `src/managed/Nota.App/MainWindow.Input.cs` |
-| Piano-roll note editing (arrows, ⇧ octave, ⌘A/⌘D, ⌘C/X/V, Delete, Esc) | `src/managed/Nota.App/PianoRollView.cs` (its `OnKeyDown`) |
-| Arrangement lane / clip gestures (double-click, drag) | `src/managed/Nota.App/ArrangementView*.cs` |
-| Device reorder drag | `src/managed/Nota.App/DeviceChainView.cs`, `DeviceCards/…` |
-
-`KeyToPitch` is the note layout: bare letters play notes, and `A` is **deliberately not** a
-note (it toggles automation mode) — so the "Play notes" rows must never list `A`. When that
-map changes, update the `PLAY NOTES` group (white vs. black keys, and the starting octave).
-
-## 3. Procedure
-
-1. List, from your own diff, every binding you added/changed/removed.
-2. Open the source-of-truth file(s) above and confirm the *current* behaviour of each key in
- the affected group — including ones you didn't touch, since the list may already be stale.
-3. Edit `ShortcutGroups` so every row matches. Add a row for a new binding, delete a row for a
- removed one, fix the key-cap or wording for a changed one. Put it in the right group.
-4. Build: `dotnet build src/managed/Nota.App -c Debug`.
-5. Visually verify (see [nota-ui-verify] memory): the pane can't be reached by a click in a
- headless run, so temporarily open it via an env-guarded hook in
- `MainWindow.OnDataContextChanged` (`new PreferencesWindow(new SettingsViewModel(settings),
- _vm).Show(this)`), and select the Shortcuts section (index 8 — count the sidebar entries, it moves as pages are added) — e.g. a temporary env read
- in front of the constructor's `Select(0)`. Screenshot with `screencapture -x -o -l<winid>`
- (get the id from the `winlist` swift helper), check the rows read correctly, then **revert
- the temp hooks** and rebuild.
-
-## 4. Don't forget
-
-- If the change is user-visible, it also wants a `CHANGELOG.md` entry under `## [Unreleased]`.
-- Keep the pane concise — it's a reference, not a manual. Group related keys onto one cap
- (`⌘C ⌘X ⌘V`) rather than three rows when the action is one idea.
+| Palette / menu commands and their default keys | `src/managed/Nota.Application/Palette/CommandCatalog.cs` (the gesture is the *default*) |
+| Every other key action (note map, nudges, transposes, browser, Modular, Session…), scopes, shared editing actions | `src/managed/Nota.Application/Input/KeyActionCatalog.cs` |
+| The user's keys, conflict rule, reset, persistence | `src/managed/Nota.Application/Input/KeyBindings.cs` |
+| What the page lists, in which group; the **fixed rows** (mouse, trackpad, gamepad, list and typing keys) | `src/managed/Nota.Application/Input/ShortcutLayout.cs` |
+| Asking in a handler: `Keys.Is(e, "roll.transposeUp")`, `Keys.Which(e, …)` | `src/managed/Nota.App/Input/Keys.cs` |
+| The editor (capture, conflicts, reset) | `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs` |
+
+Scopes (research R3 in `specs/096-custom-shortcuts`): Global, Arrangement and Notes are
+window-wide and conflict with each other; Session, PianoRoll, AudioEditor, Devices, Browser and
+Modular are focus scopes that win while they have the keyboard. A menu chord reaches every
+scope. Copy / Cut / Paste / Duplicate / Delete / Select all / Cancel (`edit.*`) are **shared**
+— one binding read by every view, never a per-view action.
+
+## 2. Procedure
+
+1. **New key**: add a `KeyAction` (an existing command: give `CommandCatalog` its gesture; a
+ view key: `Add(...)` in `KeyActionCatalog` with a literal `Loc.T("keys.…")` title and the
+ right scope). Paired keys are one action per direction.
+2. In the handler, ask `Keys.Is(e, id)` / `Keys.Which(e, ids)` — never `e.Key == Key.X`. Keep
+ the handler's focus gates and order. List-navigation and typing keys (arrows in a list,
+ Return / Esc / Tab in a text box) stay fixed and are compared directly.
+3. **New gesture or fixed key**: add an `F(key, text)` row to its group in `ShortcutLayout`.
+4. Default keys must not collide (rule R3) — `KeyBindingTests` lists the pairs allowed on
+ purpose; a new one fails until it is added there with its reason.
+5. Build and run `dotnet run --project tests/Nota.SmokeTest -c Release -- --shortcuts` and
+ `-- --palette` (every action is laid out once), and `-- --localization` (new strings).
+6. Visually verify with the headless harness (memory: nota-ui-verify) —
+ `PreferencesWindow.ShowPage("Shortcuts")`, a filter, and `StartCapture` / `Propose` by
+ reflection for the editor states.
+
+## 3. Don't forget
+
+- User-visible → `CHANGELOG.md` `[Unreleased]`, and the user docs: `npm run shortcuts` in
+ nota-docs regenerates `reference/shortcuts` from the layout.
+- Tooltips naming a key: `Keys.SetTip(control, text, id)` (the default glyph in the text is
+ swapped for the user's key). Context-menu hints: `MenuKit.Bound(id)`.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eac8b602..df0a5a84 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,20 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Your own keyboard shortcuts** (#61, specs/096). Every key in Nota can now be changed in
+ **Settings → Shortcuts**: click a key, press the new one, **Confirm** — menu commands and
+ the keys that used to be fixed alike: piano-roll and arrangement editing (nudge, transpose,
+ move to track), Session, devices, the Files browser, Modular, the transport, and the
+ computer-keyboard notes (each note, octave and velocity — handy on AZERTY or Cyrillic
+ layouts). An action can have a second key. Before anything is saved the row says which
+ action already answers that key where this one works ("⌘D is used by Duplicate") and offers
+ **Replace** or **Cancel**; a key used only in another view is allowed with a note on which
+ one wins, and keys the system keeps (⌘Q, ⌘H, Alt+F4…) are refused. Changed keys carry an
+ accent dot and their default, **Edited only** lists them, each has a reset, and **Reset all
+ to defaults…** puts everything back. Only changed keys are stored, so new defaults in later
+ versions still arrive. The menu, the context menus, tooltips and the command palette show
+ your keys at once; mouse gestures and the keys of lists and text fields stay as they are,
+ listed for reference. Typing a key in the filter ("⌘T", "cmd t") finds what it does.
- **Choose the address Nota Remote shows** (#85, specs/095). On a computer with several
networks (Wi-Fi and Ethernet, a VPN, a virtual machine's network), Nota could put an address
in the QR code that the phone can't reach. Now you can choose it.
diff --git a/FEATURES.md b/FEATURES.md
index 16ca7bb7..502f0c19 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -1589,8 +1589,14 @@ audio effects after it keep running and keep their settings; saved with the proj
- **User manual** (EN / FR / RU, https://nota-daw.github.io/nota-docs/) — **Help ▸ Documentation**
opens it in the interface language, the start window links to the first-track tutorial, and
each device header menu's **Documentation** item opens that device's page.
-- **A shortcut list** in Preferences → Shortcuts, grouped by section (File, Command palette,
- Transport, Arrangement & Editing, Piano roll, Play notes, Mouse).
+- **Custom keyboard shortcuts** in Preferences → Shortcuts (specs/096): every key is
+ rebindable — menu commands, view keys (piano roll, arrangement, Session, devices, Files
+ browser, Modular) and the computer-keyboard note map — with a second key per action,
+ capture with Confirm / Cancel / Clear, conflict detection before saving (Replace or
+ Cancel; system-reserved keys refused), an edited mark with the default and a per-row reset,
+ **Edited only**, **Reset all to defaults**, and a filter that matches names and keys. Only
+ changed keys are stored; menus, context menus, tooltips and the palette follow them. Mouse
+ gestures and list / typing keys are listed read-only.
---
@@ -1670,7 +1676,7 @@ audio effects after it keep running and keep their settings; saved with the proj
code or a language file's path) sets the language for one run. On macOS the system's own
text (application menu, open and save panels) follows the language from the next start. The
Remote phone page, MCP tool descriptions and logs are not translated.
-- **Shortcuts**: the shortcut list.
+- **Shortcuts**: every keyboard shortcut, editable (custom keys, conflicts, reset); mouse gestures for reference.
- Settings, logs and autosaves live in `~/Library/Application Support/Nota/` (macOS) and
`%APPDATA%\Nota` (Windows).
diff --git a/specs/096-custom-shortcuts/checklists/requirements.md b/specs/096-custom-shortcuts/checklists/requirements.md
new file mode 100644
index 00000000..92ae9830
--- /dev/null
+++ b/specs/096-custom-shortcuts/checklists/requirements.md
@@ -0,0 +1,37 @@
+# Specification Quality Checklist: Custom keyboard shortcuts
+
+**Purpose**: Validate specification completeness and quality before proceeding to planning
+**Created**: 2026-11-13
+**Feature**: [spec.md](../spec.md)
+
+## Content Quality
+
+- [x] No implementation details (languages, frameworks, APIs)
+- [x] Focused on user value and business needs
+- [x] Written for non-technical stakeholders
+- [x] All mandatory sections completed
+
+## Requirement Completeness
+
+- [x] No [NEEDS CLARIFICATION] markers remain
+- [x] Requirements are testable and unambiguous
+- [x] Success criteria are measurable
+- [x] Success criteria are technology-agnostic (no implementation details)
+- [x] All acceptance scenarios are defined
+- [x] Edge cases are identified
+- [x] Scope is clearly bounded
+- [x] Dependencies and assumptions identified
+
+## Feature Readiness
+
+- [x] All functional requirements have clear acceptance criteria
+- [x] User scenarios cover primary flows
+- [x] Feature meets measurable outcomes defined in Success Criteria
+- [x] No implementation details leak into specification
+
+## Notes
+
+- Three clarifications answered 2026-11-13 (FR-009 primary + alternative key, FR-010 one
+ binding per shared editing action, FR-011 navigation / text keys fixed). All items pass.
+- The "Nota Context" section names the current code layout on purpose — the Nota spec
+ template asks for it to drive the plan.
diff --git a/specs/096-custom-shortcuts/contracts/actions.md b/specs/096-custom-shortcuts/contracts/actions.md
new file mode 100644
index 00000000..148c1ab0
--- /dev/null
+++ b/specs/096-custom-shortcuts/contracts/actions.md
@@ -0,0 +1,75 @@
+# Contract: the key-action catalog (096)
+
+Every editable row on Preferences → Shortcuts. Ids are stable (they key the user's settings).
+Command-catalog commands keep their ids and gestures as defaults; only the ones handled by
+view code or given a new scope are listed here, plus every new non-command action.
+"Alt." = default alternative key. ⌘ = Cmd on macOS, Ctrl elsewhere.
+
+## Shared editing actions (Global; read by every view that supports them — FR-010)
+
+| Id | Default | Alt. | Menu key |
+|----|---------|------|----------|
+| edit.copy | ⌘C | | no |
+| edit.cut | ⌘X | | no |
+| edit.paste | ⌘V | | no |
+| edit.duplicate | ⌘D | | yes |
+| edit.delete | ⌫ | ⌦ | no |
+| edit.selectAll | ⌘A | | yes |
+| edit.cancel *(new)* | Esc | | no |
+
+Consumers: arrangement clips / time range / automation, track headers, device chain + rack
+chains, piano roll notes, controller lanes (delete / cancel), Session grid, Modular (duplicate,
+delete, cancel = show fewer parameters), audio clip editor (cancel = drop warp drag), rack
+cards (cancel = end macro mapping).
+
+## Window layer
+
+| Id | Scope | Default | Notes |
+|----|-------|---------|-------|
+| transport.* (catalog) | Global | as today | Space, ⇧Space, Return, ⌘R, ⌘., ⌘L, ⌘M, ⌘⇧R |
+| view.cycleDetailTab *(new)* | Global | Tab | detail panel last used |
+| view.openMenu *(new)* | Global | F10 | Windows / Linux only; the ⌥ tap stays fixed |
+| arr.nudgeLeft / arr.nudgeRight *(new)* | Arrangement | ← / → | |
+| arr.nudgeFineLeft / arr.nudgeFineRight *(new)* | Arrangement | ⌥← / ⌥→ | |
+| arr.moveToTrackUp / arr.moveToTrackDown *(new)* | Arrangement | ⌥↑ / ⌥↓ | |
+| edit.toggleClipActive (catalog) | Arrangement | 0 | keypad 0 matches too |
+| view.showPlayhead (catalog) | Arrangement | P | |
+| notes.c, notes.cs, notes.d, notes.ds, notes.e, notes.f, notes.fs, notes.g, notes.gs, notes.a, notes.as, notes.b, notes.c2 *(new)* | Notes | A W S E D F T G Y H U J K | |
+| notes.octaveDown / notes.octaveUp *(new)* | Notes | Z / X | |
+| notes.velocityDown / notes.velocityUp *(new)* | Notes | C / V | |
+
+## Focus layer
+
+| Id | Scope | Default |
+|----|-------|---------|
+| devices.group / devices.ungroup *(new)* | Devices | ⌘G / ⌘⇧G |
+| browser.back / browser.forward / browser.up *(new)* | Browser | ⌘[ / ⌘] / ⌘↑ (alt. off macOS: Alt+← / Alt+→ / Alt+↑) |
+| browser.editPath *(new)* | Browser | ⌘L |
+| modular.fit / modular.bypass *(new)* | Modular | F / B |
+| session.launchSelection *(new)* | Session | Return |
+| session.rename *(new)* | Session | F2 |
+| session.insertScene (catalog) | Session | ⌘I |
+| roll.moveLeft / roll.moveRight *(new)* | PianoRoll | ← / → |
+| roll.transposeUp / roll.transposeDown *(new)* | PianoRoll | ↑ / ↓ |
+| roll.octaveUp / roll.octaveDown (catalog) | PianoRoll | ⇧↑ / ⇧↓ |
+| roll.shorten / roll.lengthen *(new)* | PianoRoll | ⇧← / ⇧→ |
+| roll.velocityUp / roll.velocityDown *(new)* | PianoRoll | ⌥↑ / ⌥↓ |
+| roll.velocityUpFine / roll.velocityDownFine *(new)* | PianoRoll | ⌥⇧↑ / ⌥⇧↓ |
+| roll.fitNotes / roll.fold (catalog) | PianoRoll | ⇧F / ⌥⇧F |
+
+## Fixed (read-only rows)
+
+Mouse / trackpad gestures; gamepad; the command palette's list keys (↑ ↓ PgUp PgDn Return
+⌘Return ⌥Return ⇧Return Tab ⇧Tab Esc, the `> @ + # ~` prefixes); Session selection arrows;
+the browser's Return (open folder) and preview ↑ ↓; Return / Esc / Tab while typing or
+renaming; the ⌥ tap that opens the menu; macOS ⌘Q.
+
+## Settings JSON
+
+```json
+"KeyBindings": {
+ "edit.split": { "Primary": "⌘T", "Alternative": null },
+ "notes.c": { "Primary": "Q" },
+ "transport.metronome": { "Primary": "" }
+}
+```
diff --git a/specs/096-custom-shortcuts/contracts/ui-contract.md b/specs/096-custom-shortcuts/contracts/ui-contract.md
new file mode 100644
index 00000000..44019817
--- /dev/null
+++ b/specs/096-custom-shortcuts/contracts/ui-contract.md
@@ -0,0 +1,47 @@
+# UI contract: Preferences → Shortcuts (096)
+
+Follows `DESIGN.md` (Studio): flat grey shell, one accent in three strengths (solid = live,
+soft tint = picked, accent line = values), Geist with tabular figures, sentence case.
+
+## Page header
+
+`[ Filter shortcuts… ] [Edited only ◻] [Reset all to defaults…]` — the velocity-wheel section
+stays above. "Reset all" is disabled when nothing is edited. A "Needs a decision" group
+appears first when an update produced conflicts (R6).
+
+## Editable row (34 px, as today)
+
+```
+[⌘][E] [+] Split at playhead • ⌘E ↺
+ primary alternative action title edited mark, default, reset
+```
+
+- Key caps are a button (hover: soft tint). Click → capture. The alternative slot shows its
+ caps, or a quiet `+` when empty.
+- Edited: accent dot before the title, the default as quiet caps ("default ⌘E"), and a reset
+ button `↺` (tooltip "Reset to default"). Unassigned shows "—" in the key column.
+- Read-only rows: key text in tertiary colour, no button, a "fixed" hint on hover.
+
+## Capture (in place, one row at a time)
+
+```
+[ Press a shortcut… ] Confirm Cancel Clear Assign Esc
+[ ⌘ ][ T ] Confirm Cancel Clear
+⚠ ⌘T is used by Transpose up (Piano roll). Replace Cancel
+ⓘ Elsewhere ⌘T is New track — the piano roll wins while it has focus.
+⛔ ⌘Q is reserved by macOS.
+```
+
+- The field has an accent outline while capturing; nothing fires while it is active.
+- Confirm is the primary button; it is hidden while a conflict line shows (Replace takes its
+ place). Esc = Cancel. Clicking elsewhere or leaving the window = Cancel.
+
+## Reset all
+
+Confirmation dialog: "Reset all shortcuts? Your N custom keys are replaced by the defaults."
+`[Cancel] [Reset all]`.
+
+## Filter
+
+Words match the group title, the action title, aliases and the current keys in both spellings
+(⌘T / "cmd t" / "ctrl+t"). "Edited only" narrows to edited rows (and "Needs a decision").
diff --git a/specs/096-custom-shortcuts/data-model.md b/specs/096-custom-shortcuts/data-model.md
new file mode 100644
index 00000000..59f4b68d
--- /dev/null
+++ b/specs/096-custom-shortcuts/data-model.md
@@ -0,0 +1,58 @@
+# Data model: Custom keyboard shortcuts (096)
+
+All types live in `Nota.Application/Input` unless noted. Pure managed state; nothing reaches
+the engine.
+
+## KeyScope (enum)
+
+`Global, Arrangement, Notes, Session, PianoRoll, AudioEditor, Devices, Browser, Modular`.
+`IsWindowLayer(scope)` = Global | Arrangement | Notes. See research R3.
+
+## KeyAction
+
+| Field | Type | Notes |
+|-------|------|-------|
+| Id | string | stable across versions; command ids reuse `CommandCatalog` ids |
+| Title | string | localized; the row text on the Shortcuts page |
+| Category | string | localized group title (the page's section; for commands their palette category) |
+| Scope | KeyScope | where it is live |
+| DefaultPrimary | Shortcut? | per platform (some differ off macOS) |
+| DefaultAlternative | Shortcut? | e.g. `⌦` for Delete, Alt+← for browser back off macOS |
+| IsMenuCommand | bool | has a `NativeMenuItem` (from `MainWindow.axaml`) |
+| NoMenuKey | bool | the menu shows no gesture (copy / cut / paste / delete) |
+| Fixed | bool | listed but not editable (macOS ⌘Q) |
+| Aliases | string[] | extra filter words (from the command catalog) |
+
+## KeyBindingOverride (settings, `Nota.Application.Settings.KeyBindings`)
+
+`Dictionary<string actionId, KeyBindingOverride>`; `KeyBindingOverride { string? Primary;
+string? Alternative; }` — `null` = default, `""` = unassigned, else glyph text.
+
+## KeyBindings (service)
+
+State: catalog, overrides, effective map `(scope, Shortcut) → actionIds`, `NeedsDecision`
+set (defaults shadowed by user keys after an update).
+
+| Operation | Behaviour |
+|-----------|-----------|
+| `Current(id, slot)` | effective Shortcut or none |
+| `IsEdited(id)` | any slot differs from default |
+| `Resolve(scope, chord)` | the action in that scope bound to chord, or null |
+| `Matches(id, chord)` | chord equals the primary or the alternative |
+| `FindConflicts(id, slot, chord)` | actions that conflict (rule R3), each with scope |
+| `FindShadows(id, chord)` | non-conflicting reuses in other layers (informational) |
+| `Validate(chord)` | `Ok / Reserved(reason) / Incomplete` |
+| `Apply(change)` | one atomic change: set slot (+ clear the conflicting slots on Replace) |
+| `Reset(id)` / `ResetAll()` | back to defaults; `Reset` reports conflicts first |
+| `Changed` event | raised after every applied change; persisted via `ISettingsService.Save` |
+
+### State transitions of a row
+
+`Idle → Capturing → Proposed(chord) → [Conflict(list) →] Saved | Cancelled`;
+`Idle → Cleared` (Clear), `Edited → Idle` (Reset / equals default again).
+
+## Shortcuts page layout (`Nota.App`)
+
+`ShortcutLayout` (Nota.Application/Input): ordered groups `(title, rows)` built from the catalog categories; a row is `Action(id)` (editable, from the
+catalog) or `Fixed(keyText, description)` (mouse gestures, navigation / text keys, gamepad).
+Every catalog action appears in exactly one group (smoke-tested).
diff --git a/specs/096-custom-shortcuts/plan.md b/specs/096-custom-shortcuts/plan.md
new file mode 100644
index 00000000..dd8de530
--- /dev/null
+++ b/specs/096-custom-shortcuts/plan.md
@@ -0,0 +1,120 @@
+# Implementation Plan: Custom keyboard shortcuts
+
+**Branch**: `feat/custom-shortcuts` | **Date**: 2026-11-13 | **Spec**: [spec.md](spec.md)
+
+**Input**: Feature specification from `specs/096-custom-shortcuts/spec.md` (issue #61)
+
+## Summary
+
+Every keyboard shortcut becomes a catalog entry (id, scope, default primary + alternative)
+in a new `KeyActionCatalog`, built from the command catalog plus ~50 view-level actions. A
+`KeyBindings` service layers the user's overrides (stored in settings, only changed slots) on
+the defaults, answers lookups, and finds conflicts by a layer rule (research R3). Every
+hand-written key comparison in the views asks the service instead (`Keys.Is(e, id)`), keeping
+its focus gates and order, so with no overrides nothing behaves differently. Preferences →
+Shortcuts becomes an editor (capture, conflicts, edited mark, reset, Reset all), and the menu,
+tooltips and palette re-read keys when bindings change.
+
+## Nota: Read Before Planning
+
+UI → [`DESIGN.md`](../../DESIGN.md) + `nota-design`; keyboard bindings → `nota-shortcuts`;
+docs → `nota-docs`, `nota-features`. No engine work.
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10 (managed app only)
+
+**Primary Dependencies**: Avalonia (existing). No new dependency.
+
+**Storage**: `settings.json` (`Settings.KeyBindings`, via `ISettingsService`; `NOTA_DATA_DIR`
+honoured as today).
+
+**Audio-Thread Impact**: None — UI / input only; note-map keys still call the existing
+`Engine.NoteOn/NoteOff` from the UI thread.
+
+**Testing**: `tests/Nota.SmokeTest` (new `KeyBindingTests`, extended `PaletteTests`,
+`ShortcutBuilderTests`); in-app check per [quickstart.md](quickstart.md).
+
+**Target Platform**: macOS, Windows, Linux.
+
+**Project Type**: desktop app.
+
+**Performance Goals**: a key lookup is a dictionary hit per key press; no allocation per press
+beyond today's.
+
+**Constraints**: default behaviour unchanged (FR-023); macOS menu key equivalents fire before
+views (R3); text fields keep typing.
+
+**Scale/Scope**: ~110 command actions + ~50 new actions; ~12 handler files.
+
+## Constitution Check
+
+| Principle | Status |
+|-----------|--------|
+| 0 Approved issue | #61 `approved`, scope comment by the maintainer; PR `Closes #61` |
+| I Real-time safety | N/A — no engine / audio-thread change |
+| II Boundary | N/A — no C ABI change |
+| III Licensing | new files carry SPDX headers; no dependency |
+| IV Verification | `scripts/build.sh` + smoke tests extended (no engine behaviour change) |
+| V One change | one feature PR; the nota-docs generator update is its own PR in that repo |
+| VI Docs | CHANGELOG, FEATURES.md, nota-docs page + RU twin, nota-shortcuts |
+| VII Spec-first | this spec / plan / tasks |
+| VIII | no rule bent |
+
+Post-design re-check: passes (nothing above changed).
+
+## Project Structure
+
+### Documentation (this feature)
+
+```text
+specs/096-custom-shortcuts/
+├── spec.md · plan.md · research.md · data-model.md · quickstart.md
+├── contracts/actions.md # the action catalog (ids, scopes, defaults)
+├── contracts/ui-contract.md # the Shortcuts editor
+└── tasks.md
+```
+
+### Source Code
+
+```text
+src/managed/Nota.Application/
+├── Input/KeyScope.cs # new: scopes + layer
+├── Input/KeyAction.cs # new: catalog entry
+├── Input/KeyActionCatalog.cs # new: commands imported + view actions
+├── Input/KeyBindings.cs # new: overrides, lookup, conflicts, reset, persistence
+├── Input/ReservedKeys.cs # new: per-platform OS-reserved chords
+└── Settings.cs # + KeyBindings dictionary, KeyBindingOverride
+src/managed/Nota.App/
+├── Input/KeyTokens.cs # new: Avalonia Key ⇄ token
+├── Input/ShortcutAvaloniaExtensions.cs # ToGesture via KeyTokens; FromKeyEvent
+├── Input/Keys.cs # new: app facade (Is, Resolve, Capturing, KeyTips)
+├── MainWindow.Input.cs # handlers → Keys.Is
+├── MainWindow.MenuKeys.cs # gestures from bindings; refresh on change
+├── PianoRollView.cs · PianoRollView.Controllers.cs · SessionView.cs · ModularView.cs
+├── DeviceChainView.Clipboard.cs · BrowserView.Files.cs · AudioClipEditor / rack Esc paths
+├── PreferencesWindow.cs # ShortcutGroups → ShortcutLayout; editor UI
+├── PreferencesWindow.Shortcuts.cs # new: capture, conflict line, reset, Reset all
+└── App startup # KeyBindings registered in DI, loaded from settings
+src/managed/Nota.Presentation/PaletteProviders.cs # current key in hints
+src/managed/Nota.Application/Localization/en.json # new strings
+tests/Nota.SmokeTest/KeyBindingTests.cs # new
+tests/Nota.SmokeTest/PaletteTests.cs # layout covers every action
+```
+
+**Structure Decision**: domain-free logic (catalog, conflicts, persistence) in
+Nota.Application so the smoke test can drive it without UI; Avalonia-specific mapping and
+the editor in Nota.App.
+
+## Delivery order
+
+1. Catalog + KeyBindings + settings + tests (no behaviour change).
+2. Handlers switch to `Keys.Is` (behaviour identical with defaults) — US1 dispatch.
+3. Editor: capture / confirm / clear (US1), conflicts (US2), mark / filter / reset (US3),
+ note map rows (US4).
+4. Propagation: menu, tooltips, palette.
+5. Docs, CHANGELOG, FEATURES, build.sh green.
+
+## Complexity Tracking
+
+None.
diff --git a/specs/096-custom-shortcuts/quickstart.md b/specs/096-custom-shortcuts/quickstart.md
new file mode 100644
index 00000000..ae5da50a
--- /dev/null
+++ b/specs/096-custom-shortcuts/quickstart.md
@@ -0,0 +1,30 @@
+# Quickstart: validating custom keyboard shortcuts (096)
+
+## Automated
+
+```bash
+scripts/build.sh
+```
+
+The smoke test gains `KeyBindingTests` (catalog and conflict rules, persistence round trip,
+reserved keys, reset, update migration) and an extended `PaletteTests.RegistryDrift` (every
+action is laid out on the Shortcuts page; the defaults have no conflict). All must pass.
+
+## In the app (macOS, then Windows / Linux when available)
+
+Use a scratch data dir: `NOTA_DATA_DIR=/tmp/n096data`.
+
+1. Settings → Shortcuts: every keyboard row shows a key-cap button; mouse rows are quiet text.
+2. Split at playhead → click → press ⌘T → Confirm. Edit menu shows ⌘T. ⌘T splits, ⌘E does
+ nothing. The row has the edited dot and "default ⌘E".
+3. Piano roll "Transpose up" → ⌘D → conflict line names Duplicate → Replace → Duplicate shows
+ "—" and edited. ⌘D in the piano roll transposes.
+4. Arrangement "Nudge left" → ⇧F (a piano-roll key) → accepted with the "elsewhere" note.
+5. Capture ⌘Q (macOS) / Alt+F4 → refused with the reason.
+6. Notes: C → Q. Arm a MIDI track, Q plays C4, A doesn't.
+7. Edited only → the four rows above. Reset one → back to default (Replace-check if taken).
+ Reset all → confirm → nothing edited.
+8. Restart with edits: they survive. Hand-edit `settings.json`: an unknown id and a junk key
+ are skipped, the app starts.
+9. Hover Record: the tooltip shows the current key after rebinding ⌘R.
+10. Palette (⌘⇧P) "split": shows the current key.
diff --git a/specs/096-custom-shortcuts/research.md b/specs/096-custom-shortcuts/research.md
new file mode 100644
index 00000000..7bddcb0c
--- /dev/null
+++ b/specs/096-custom-shortcuts/research.md
@@ -0,0 +1,152 @@
+# Research: Custom keyboard shortcuts (096)
+
+## R1 — Where keys are decided today
+
+- `CommandCatalog` (Nota.Application/Palette) declares ~110 commands; ~45 carry a glyph
+ gesture. `MainWindow.MenuKeys.cs` copies it onto the `NativeMenuItem.Gesture` once at start
+ (macOS: AppKit fires it as a key equivalent; Windows / Linux: `TryMenuShortcut` matches it in
+ `HandleKeyDown`). The palette copies `PaletteCommand.Gesture` into its items.
+- Everything else compares `e.Key` / `e.KeyModifiers` by hand. Files with song-acting keys:
+ `MainWindow.Input.cs` (transport tunnel, Esc chain, arrangement clipboard / nudge / delete /
+ 0 / P, track-header keys, Z X C V, the `KeyToPitch` note map, `GridCommandFor`),
+ `PianoRollView.cs` (`OnKeyDown`: delete, ⇧F, ⌥⇧F, Esc, arrows ± ⇧/⌥, ⌘A D C X V),
+ `PianoRollView.Controllers.cs` (Delete, Esc), `SessionView.cs` (`HandleKey`), `ModularView.cs`
+ (F, B, ⌘D, Delete, Esc), `DeviceChainView.Clipboard.cs` (⌘G ⌘⇧G, ⌘C X V D, Delete, Esc),
+ `BrowserView.Files.cs` (⌘L ⌘[ ⌘] ⌘↑, Alt+←→↑ off macOS), `AudioClipEditorView` (Esc via
+ `CancelGesture`), rack cards (Esc via `RackCardState`).
+- Keys in dialogs, menus, the palette list, text boxes, value entry (`ValueEntry`, `DragNumber`),
+ rename flyouts, `MenuKit` navigation, Welcome / Export / SaveChanges windows are
+ list-navigation or text-entry keys → fixed (FR-011).
+- The Shortcuts page is `PreferencesWindow.ShortcutGroups`: `(title, (Key, Action)[])`, where
+ `Key` is either glyph tokens or a localized gesture description. `nota-docs/scripts/shortcuts.mjs`
+ parses this array to generate the manual's shortcuts page; `PaletteTests.RegistryDrift`
+ checks every catalog gesture is listed there.
+
+## R2 — One catalog, two layers
+
+**Decision**: a new `KeyActionCatalog` (Nota.Application/Input) lists every keyboard action:
+id, title, group, scope, default primary, default alternative, flags. Command-palette
+commands are *imported* from `CommandCatalog` (same id, title, gesture as default) so there
+is one id space; non-command actions (note map, nudges, transposes, …) are declared next to
+them. A `KeyBindings` service (Application) holds the user's overrides on top of the defaults
+and answers "which action does this chord mean in this scope" and "what is the current key
+of action X". Views ask through a small App-side facade (`Keys.Is(e, "roll.transposeUp")`).
+
+**Rationale**: smallest change to the many hand-written handlers — each `e.Key == Key.X && mods`
+becomes `Keys.Is(e, id)`; the handlers keep their order, gates (focus, selection) and
+fall-through, so default behaviour stays identical (FR-023). `CommandCatalog` keeps its role
+for the palette and menu; its `Gesture` becomes the *default* only.
+
+**Alternatives**: a central dispatcher that owns every key and calls into views — rejected:
+rewrites focus routing in ~10 views at once, high regression risk for one release.
+Moving gestures out of `CommandCatalog` — rejected: the palette tests and docs read it.
+
+## R3 — Scopes and the conflict rule
+
+The app already routes by focus: a focused piano-roll grid, Session grid, device chain,
+Modular canvas or Files browser handles its keys before the main window; the main window's
+`HandleKeyDown` then runs Global, Arrangement and note-map keys in a fixed order. On macOS a
+chord carried by a menu item fires as a key equivalent *before* any view sees the key (the
+code comments on ⌘D / ⌘⇧D say so), and the menu handlers route by focus themselves
+(`OnMenuDuplicate`).
+
+**Decision** — scopes:
+
+| Scope | Layer | Live when |
+|-------|-------|-----------|
+| Global | window | the main or floating detail window has the keyboard |
+| Arrangement | window | the Arrangement is shown |
+| Notes | window | computer-keyboard notes (lowest priority) |
+| Session | focus | the Session grid has focus |
+| PianoRoll | focus | the piano-roll grid (or its controller lanes) has focus |
+| AudioEditor | focus | the audio clip editor is visible |
+| Devices | focus | the device chain / rack card has focus |
+| Browser | focus | the Files tab of the browser has focus |
+| Modular | focus | the Modular canvas has focus |
+
+Two actions **conflict** on a combination when
+1. they are in the same scope, or
+2. both scopes are window-layer (they are live together, in a fixed order the user can't see), or
+3. either binding is a *menu chord* (the action has a menu item, and the combination is a
+ chord or a bare F-key) — on macOS it fires before the focused view, so it reaches every scope;
+
+— **unless both bindings are their shipped defaults**. Shipped defaults are curated (and
+smoke-tested): today ⌘L is both Loop and the Files browser's path field, ⌘G both Group tracks
+and Group devices, Esc both the arrangement and the rack card; those keep working as they do.
+
+A focus-scope key that reuses a window-layer key is **not** a conflict (the focused view wins,
+deterministically); the editor shows it as a note ("Elsewhere ⌘K is Save").
+
+Shared editing actions (FR-010) — `edit.copy/cut/paste/duplicate/delete/selectAll` and a new
+`edit.cancel` (Esc) — are Global actions read by every view that supports them, so they
+never conflict with themselves across contexts.
+
+**Alternatives**: "same scope only" (the issue's sketch) — rejected: Global vs Arrangement would
+let ⌘S be both Save and Split, and on macOS the menu would win silently. "Global overlaps
+everything" — rejected: it flags today's defaults (Return = Stop vs Return = launch slot).
+
+## R4 — Key tokens and matching
+
+**Decision**: a binding is a `Shortcut` (existing value type: modifiers + key token). Key
+tokens (canonical, stored in settings): `A`–`Z`, `0`–`9`, `F1`–`F24`, `Space`, `Return`, `Tab`,
+`Esc`, `⌫` (Backspace — the macOS Delete key), `⌦` (forward delete), `←` `→` `↑` `↓`, `PgUp`,
+`PgDn`, `Home`, `End`, and the punctuation `, . / ; ' [ ] \ - = \``. A new
+`KeyTokens` (Nota.App/Input) maps Avalonia `Key` ⇄ token; `ToGesture` uses it so menus accept
+every token. Keypad digits match the digit token (today ⌘1 and ⌘Num1 both narrow the grid).
+Modifiers match exactly (Primary = ⌘ on macOS / Ctrl elsewhere, Ctrl = ⌃ on macOS only).
+
+Layouts: Avalonia reports `Key` per OS key code; capture records exactly the `Key` the app
+receives, so a binding always matches the key that was pressed when it was recorded, on any
+layout. Display uses the token (Latin names), plus the layout character from `KeySymbol` in
+the capture field as a hint when it differs.
+
+**Rationale**: reuses `Shortcut` (glyph formatting, platform spelling, key caps already tested).
+
+## R5 — OS-reserved combinations
+
+**Decision**, refused in capture with a reason (FR-008):
+- macOS: ⌘Q (Quit lives in the app menu; `file.exit` is fixed on macOS), ⌘H, ⌥⌘H, ⌘Tab,
+ ⌘⇧Tab, ⌘Space, ⌃Space, ⌘\`, ⌘⇧3, ⌘⇧4, ⌘⇧5, ⌃⌘Q, ⌥⌘Esc.
+- Windows: Alt+F4, Alt+Tab, Alt+Esc, Alt+Space, Ctrl+Esc, Ctrl+Shift+Esc, Ctrl+Alt+Delete,
+ any Win-key combination.
+- Linux: Alt+F4, Alt+Tab, Ctrl+Alt+Delete, Ctrl+Alt+F1–F12, any Super combination.
+The editor says it can't detect every external conflict (global shortcuts of other apps).
+
+## R6 — Persistence
+
+**Decision**: `Settings.KeyBindings : Dictionary<string, KeyBindingOverride>` keyed by action
+id; `KeyBindingOverride { string? Primary; string? Alternative; }` — `null` = the default for
+that slot, `""` = unassigned, else glyph text (`Shortcut.ToGlyphs`). An entry is removed when
+both slots are back to default. On load: unknown ids and unparsable glyphs are skipped and
+logged; a user override that now collides with a *new default* (rule R3) makes the default
+side inactive at run time and the page lists it under "Needs a decision" — nothing is written
+until the user resolves it (FR-021).
+
+**Rationale**: only changed slots are stored (FR-020); JSON stays readable by older versions
+(they ignore the unknown property).
+
+## R7 — Propagation
+
+- **Menus**: `MenuKeys` re-applies `item.Gesture` for every menu command on `KeyBindings.Changed`
+ (Avalonia's native menu exporter updates the AppKit key equivalent on property change) and
+ rebuilds `_menuShortcuts`. Actions flagged `NoMenuKey` (copy / cut / paste / delete — a menu
+ key equivalent would steal them from text fields) show no gesture, as today.
+- **Tooltips**: tooltip strings embed the default glyph ("Record (⌘R)"). `KeyTips.Set(control,
+ text, actionId)` swaps the default glyph for the current key (or drops the parenthesis when
+ unassigned) and re-applies on change — translations need no new placeholders. Covers the
+ code-set tips (record, loop record, metronome, maximize, automation, snap chip, loop) and the
+ XAML tips that name catalog keys (#60 extends this later to every control).
+- **Palette**: `PaletteProviders` reads the current key from `KeyBindings` instead of
+ `PaletteCommand.Gesture`; the palette index is rebuilt on change.
+- **Docs generator / tests**: `ShortcutGroups` becomes a layout list of action ids and fixed
+ rows; `nota-docs/scripts/shortcuts.mjs` needs a matching update (separate nota-docs PR), and
+ `PaletteTests.RegistryDrift` checks every catalog action appears in the layout.
+
+## R8 — Capture and suppression
+
+**Decision**: capture mode is owned by the Preferences window: while a row captures, the
+window's tunnel `KeyDown` handler takes every key (`Handled = true`), and a static
+`Keys.Capturing` flag makes `MainWindow` (menu shortcuts on Windows / Linux, transport tunnel,
+note map) ignore keys. On macOS menu key equivalents are disabled during capture by clearing
+the menu gestures and restoring them afterwards. Esc cancels; an "Assign Esc" button assigns
+it. Losing window focus cancels capture.
diff --git a/specs/096-custom-shortcuts/spec.md b/specs/096-custom-shortcuts/spec.md
new file mode 100644
index 00000000..0980b547
--- /dev/null
+++ b/specs/096-custom-shortcuts/spec.md
@@ -0,0 +1,329 @@
+# Feature Specification: Custom keyboard shortcuts
+
+**Feature Branch**: `feat/custom-shortcuts`
+
+**Created**: 2026-11-13
+
+**Status**: Draft
+
+**Input**: Issue [#61](https://github.com/nota-daw/nota/issues/61) (approved for 0.60.1):
+"Custom keyboard shortcuts: edit, detect conflicts, mark changed, reset to default". The
+maintainer's scope comment widens it: **every keyboard shortcut in Nota is rebindable** in
+Preferences → Shortcuts, not only the command-palette commands; no read-only keyboard rows
+remain. Mouse gestures stay read-only. Export / import of shortcut sets and presets
+("Ableton-like") are out of scope.
+
+## Nota Context *(fill in — drives plan and tasks)*
+
+**Feature area** *(pick the main one)*:
+
+- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table
+- [x] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation
+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)
+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed
+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`
+- [ ] Docs only
+
+**Nota docs to keep in mind** *(links relative to `specs/<slug>/`, where this file lands)*:
+[`ARCHITECTURE.md`](../../ARCHITECTURE.md) (AR rules),
+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) (licensing, dependency policy, PR
+expectations), [`BUILD.md`](../../BUILD.md), [`DESIGN.md`](../../DESIGN.md),
+[`FEATURES.md`](../../FEATURES.md).
+
+**Where things stand today**: about a hundred menu / palette commands carry a default key
+in the command catalog, and the menu reads its keys from there. Everything else — piano-roll
+and audio-clip editing keys, Session keys, track / device / browser / Modular / rack keys,
+grid keys, the computer-keyboard note map, transport keys handled directly in the windows'
+key handlers — is hard-coded where it is handled and only *described* in a hand-written
+list in Preferences → Shortcuts, mixed with mouse gestures. That list is read-only.
+
+## Clarifications
+
+### Session 2026-11-13
+
+- Q: How many keys per action? → A: A primary plus one optional alternative (FR-009).
+- Q: Shared editing actions (Copy, Cut, Paste, Duplicate, Delete, Select all) — one row or
+ one per context? → A: One binding each, live in every context that supports it (FR-010).
+- Q: List-navigation and text-entry keys — rebindable? → A: No, fixed and shown read-only
+ (FR-011).
+- Planning refinement (research R3): a context with keyboard focus deterministically wins
+ over the window-wide keys, so reuse across those layers is allowed and shown as a note;
+ window-wide scopes overlap each other; a key that a menu item carries reaches every scope
+ (on macOS the menu fires first). Pairs that ship in the defaults are never reported.
+
+## User Scenarios & Testing *(mandatory)*
+
+### User Story 1 - Rebind a shortcut (Priority: P1)
+
+A producer coming from another DAW wants "Split" on ⌘T instead of ⌘E. They open
+Preferences → Shortcuts, find "Split at playhead", click its key, press ⌘T, confirm. From
+then on ⌘T splits, ⌘E does nothing, the Edit menu shows ⌘T, and the setting survives a
+restart.
+
+**Why this priority**: it is the feature; everything else protects or explains it.
+
+**Independent Test**: rebind one command and one non-catalog key (for example piano-roll
+"transpose up"), restart the app, press both new keys in their views — the actions fire;
+the old keys do not.
+
+**Acceptance Scenarios**:
+
+1. **Given** the Shortcuts page, **When** the user clicks a shortcut's key, **Then** the
+ row enters a visible capture mode ("Press a shortcut…") and no app shortcut fires while
+ it waits.
+2. **Given** capture mode, **When** the user presses ⌘T, **Then** the proposed combination
+ is shown in the row with Confirm / Cancel / Clear controls, and nothing is saved yet.
+3. **Given** a proposed combination, **When** the user confirms, **Then** the action
+ answers the new key everywhere it applies, the old key is free, and the binding is kept
+ across restarts.
+4. **Given** capture mode, **When** the user cancels, **Then** the previous binding stays
+ exactly as it was.
+5. **Given** a shortcut, **When** the user chooses Clear, **Then** the action has no key
+ (it stays reachable from menus / the palette) and the row shows it as unassigned.
+6. **Given** the user rebinds a menu command on macOS, **Then** the menu bar shows the new
+ key equivalent immediately, without a restart.
+7. **Given** a rebound key, **Then** tooltips that mention the key and the command
+ palette's key hints show the new key.
+
+---
+
+### User Story 2 - Conflicts are caught before saving (Priority: P1)
+
+The user presses ⌘D for an arrangement action, but ⌘D is Duplicate. Before anything is
+saved the row says "⌘D is used by Duplicate" and offers *Replace* (Duplicate loses ⌘D) or
+*Cancel*. A piano-roll key may reuse an arrangement key — the piano roll wins while it has
+the keyboard, so that is not a conflict.
+
+**Why this priority**: without it, rebinding silently breaks other actions or makes one
+key fire two things.
+
+**Independent Test**: assign a key already used in an overlapping scope → conflict shown,
+Replace moves it and leaves the other action unassigned; assign a key used only in a
+non-overlapping scope → accepted with at most an informational note.
+
+**Acceptance Scenarios**:
+
+1. **Given** a proposed combination used by another action whose scope overlaps (FR-012),
+ **When** it is proposed, **Then** the row names every affected action and its scope and
+ offers Replace / Cancel; Confirm alone is not available.
+2. **Given** Replace, **Then** each conflicting action loses that key (becomes unassigned
+ and marked edited) and the new binding is saved — as one change.
+3. **Given** a combination used only by actions in scopes that don't overlap with this one,
+ **Then** it is accepted; when the other use is in a different layer the row notes where
+ else the key is used and which one wins.
+4. **Given** an OS-reserved combination (⌘Q, ⌘H, ⌘Tab, ⌘Space on macOS; Alt+F4, Alt+Tab,
+ Win-key combinations on Windows; equivalents on Linux), **Then** it is refused with a
+ short reason, and nothing changes.
+5. **Given** a bare modifier (⇧ alone, ⌘ alone), **Then** capture keeps waiting for a
+ complete combination.
+
+---
+
+### User Story 3 - See what differs from default and get back (Priority: P2)
+
+After a few weeks of tweaking, the user wants to see what they changed and undo one or all
+of it.
+
+**Why this priority**: personalisation without a way back is risky, but the feature is
+usable without it.
+
+**Independent Test**: edit three shortcuts, turn on "Edited only" — exactly those three
+show, each with an edited mark and its default; reset one; Reset all → confirm → none
+remain edited.
+
+**Acceptance Scenarios**:
+
+1. **Given** an edited shortcut (changed or cleared), **Then** its row carries an accent
+ mark and shows the default key next to the current one.
+2. **Given** the filter, **When** "Edited only" is on, **Then** only edited rows show; the
+ text filter matches action names and current keys (typing "⌘T" or "cmd t" finds the
+ action bound to ⌘T).
+3. **Given** an edited row, **When** the user presses its Reset button, **Then** the default
+ comes back; if the default key is now used by another action in an overlapping scope,
+ the same conflict prompt as in Story 2 appears first.
+4. **Given** Reset all to defaults, **Then** a confirmation explains that every custom key
+ will be replaced; on confirm all bindings return to defaults and no row is marked.
+5. **Given** a row whose binding was changed back by hand to its default, **Then** it is no
+ longer marked edited.
+
+---
+
+### User Story 4 - Play notes on a non-US keyboard (Priority: P3)
+
+A user on an AZERTY or Cyrillic layout rebinds the computer-keyboard note map (white keys,
+black keys, octave down / up, velocity down / up) to keys that sit where they want them.
+
+**Why this priority**: valuable for a specific group; the note map is a set of many keys
+that otherwise behaves like any other binding.
+
+**Independent Test**: rebind the C note and octave-up, arm an instrument track, press the
+new keys — the right notes sound; the old keys don't.
+
+**Acceptance Scenarios**:
+
+1. **Given** the note-map rows, **Then** each note and each octave / velocity key is its
+ own rebindable row.
+2. **Given** a note key bound to a letter, **Then** it plays only where computer-keyboard
+ notes already play today, and the conflict check treats it like any key in that scope.
+
+---
+
+### Edge Cases
+
+- Settings hold a custom key for an action that no longer exists after an update: it is
+ ignored (no crash) and kept out of the list; nothing else is lost.
+- A new version adds an action whose default key a user has already assigned to another
+ action: the user's binding wins; the new action's default is inactive and the Shortcuts
+ page lists it under "Needs a decision".
+- A new version changes the default of an action the user never touched: the user gets the
+ new default (only edited bindings are stored).
+- The settings file is damaged or hand-edited with an unparsable key: that entry is dropped
+ with a log line; every other binding loads.
+- Capture is started and the Preferences window loses focus: capture cancels.
+- Esc during capture cancels it; Esc can still be *assigned* through the explicit
+ "Assign Esc" option offered in capture mode.
+- Keyboard layouts: a binding is recorded as the key Nota receives when it is pressed, so it
+ always matches that same key later on the same layout; it is shown with platform modifier
+ names (⌘⌥⇧ on macOS, Ctrl / Alt / Shift on Windows and Linux).
+- While a text field has focus, typing goes to the field as today; no binding hijacks it.
+- Two actions in overlapping scopes end up with the same key through an old settings file:
+ on load the user's later one keeps it and the other is listed under "Needs a decision".
+
+## Requirements *(mandatory)*
+
+### Functional Requirements
+
+**One catalog of bindings**
+
+- **FR-001**: Every keyboard binding in Nota MUST come from one binding catalog: each
+ action has a stable id, a name, a group (for the list), a scope (where it works) and a
+ default combination — or none. The code that handles a key MUST ask the catalog which
+ action a combination means instead of comparing keys itself.
+- **FR-002**: The catalog MUST cover, at minimum: the menu / palette commands; transport
+ keys; window and view keys; arrangement editing (nudge, move to track, delete, …); grid
+ keys; track, device, browser-files, rack, Modular and Session keys; piano-roll and
+ audio-clip-editor keys; the computer-keyboard note map (each note, octave down / up,
+ velocity down / up); the command-palette toggle. Paired keys ("← →", "⌘Z ⌘⇧Z") become one
+ action per direction.
+- **FR-003**: Scopes MUST express where a key is live: window-wide scopes (Global,
+ Arrangement, computer-keyboard Notes) and focus scopes that handle their own keys while
+ they have the keyboard (Session grid, Piano roll, Audio clip editor, Devices, Browser,
+ Modular). Which scopes overlap MUST be defined once and used by the conflict check and the
+ key dispatch alike.
+- **FR-004**: Mouse gestures (drag, click, modifier + click, wheel, pinch) and the fixed
+ navigation / text keys of FR-011 MUST stay in the list as read-only rows, visually
+ distinct from editable rows.
+
+**Editing**
+
+- **FR-005**: Clicking a keyboard row's key MUST enter capture mode for that row only;
+ while capturing, no app shortcut, menu key equivalent or note-map key fires.
+- **FR-006**: Capture MUST show the proposed combination before it is saved, with
+ Confirm, Cancel and Clear (unassign); Esc cancels, and an explicit option assigns Esc.
+- **FR-007**: Capture MUST accept letters, digits, punctuation, function keys, arrows,
+ navigation keys, Space, Return, Tab, Delete / Backspace, with any combination of the
+ platform's modifiers; a bare modifier MUST NOT complete capture.
+- **FR-008**: OS-reserved combinations MUST be refused with a short reason. The reserved
+ list is per platform (research R5).
+- **FR-009**: Each action MUST have a primary combination and MAY have one alternative
+ combination; both are edited, conflict-checked, marked and reset the same way. Today's
+ pairs (Delete and Backspace) become primary + alternative of one action.
+- **FR-010**: Shared editing actions — Copy, Cut, Paste, Duplicate, Delete, Select all, and
+ Esc's cancel / deselect — MUST each be one action with one binding that applies in every
+ context that supports it (tracks, devices, arrangement clips, notes, Session, Modular).
+ Their scope is Global for the conflict check.
+- **FR-011**: List-navigation and text-entry keys MUST stay fixed: arrows / PgUp / PgDn /
+ Return / Tab / ⇧Tab / Esc inside the command palette and lists (Session selection arrows,
+ the browser's Return), and Return / Esc / Tab while typing a value or renaming. They are
+ listed read-only next to the mouse gestures. Context keys that act on the song (nudge
+ clips with ← →, transpose notes with ↑ ↓, Esc to cancel a gesture or clear a selection,
+ Return to launch a Session slot) are not navigation keys and stay rebindable.
+
+**Conflicts**
+
+- **FR-012**: Before saving, the editor MUST find every action that would answer the
+ proposed combination at the same time as the edited action — same scope, both
+ window-wide, or either carried by a menu item — and name each with its scope. Pairs where
+ both bindings are the shipped defaults are not reported.
+- **FR-013**: On conflict the user MUST choose Replace (the other actions lose that key) or
+ Cancel; a conflicting binding is never saved silently.
+- **FR-014**: Combinations used only in non-overlapping scopes MUST be accepted; a reuse
+ across layers (focus vs window-wide) is shown as a note saying which wins.
+- **FR-015**: Replace, a single reset and Reset all MUST each apply as one change: either
+ every affected binding changes, or none does.
+
+**Visibility and reset**
+
+- **FR-016**: A binding that differs from its default (including cleared) MUST be marked
+ in its row, with the default shown; the mark MUST disappear when the binding equals its
+ default again.
+- **FR-017**: The Shortcuts filter MUST offer "Edited only" and MUST match action names,
+ group names and current key combinations (both symbol and spelled forms, e.g. "⌘T" and
+ "cmd t").
+- **FR-018**: Each edited row MUST have a Reset control; resetting MUST run the conflict
+ check against the default key first.
+- **FR-019**: "Reset all to defaults" MUST ask for confirmation, then return every binding
+ to its default.
+
+**Persistence and propagation**
+
+- **FR-020**: Only bindings that differ from the default MUST be stored, keyed by action
+ id, in the app settings; unchanged actions follow the defaults of the running version.
+- **FR-021**: Stored bindings for unknown action ids or unparsable keys MUST be skipped
+ without losing the rest; collisions introduced by new defaults MUST surface on the
+ Shortcuts page ("Needs a decision") rather than being resolved silently.
+- **FR-022**: A changed binding MUST take effect at once: key handling, the macOS menu key
+ equivalents, menu shortcut text on Windows / Linux, tooltips that mention keys, and the
+ command palette's key hints.
+- **FR-023**: Default behaviour MUST NOT change: with no custom bindings every key does
+ exactly what it does today.
+
+### Key Entities
+
+- **Action**: something a key can trigger. Id (stable across versions), name, group,
+ scope, default primary and alternative combinations (optional).
+- **Scope**: where an action's key is live; window-wide or focus layer.
+- **Key combination**: a key plus modifiers, shown in platform notation.
+- **Custom binding**: a stored override for one action slot — a combination or "unassigned".
+- **Conflict**: a proposed combination plus the set of actions in overlapping scopes that
+ already answer it.
+
+## Success Criteria *(mandatory)*
+
+### Measurable Outcomes
+
+- **SC-001**: 100 % of the keyboard rows in Preferences → Shortcuts are editable except the
+ fixed list-navigation / text-entry keys (FR-011); the other read-only rows are mouse /
+ trackpad gestures and gamepad buttons.
+- **SC-002**: A user can find an action and rebind it in under 20 seconds.
+- **SC-003**: No combination ever triggers two actions at once, under any sequence of
+ edits, replaces and resets.
+- **SC-004**: With no custom bindings, every key in every view behaves exactly as before
+ (existing smoke and UI checks pass unchanged).
+- **SC-005**: Custom bindings survive restart and an app update; a binding for a removed
+ action never prevents the app from starting.
+- **SC-006**: After a rebind, the menu, tooltips and palette show the new key with no
+ restart.
+
+## Assumptions
+
+- Gamepad buttons are not keyboard shortcuts; they stay read-only (they are mapped through
+ MIDI learn).
+- Export / import of shortcut sets and presets are out of scope (issue: "optional later").
+- Bindings are app-wide (one set per user), not per project.
+- Undo of shortcut edits is the per-row Reset and Reset all, not the project's undo
+ history (project undo is about the song).
+- Layout-independent "position" bindings and multi-key chords (press A, then B) are out of
+ scope.
+- Keypad digits act as the digit keys (as today, ⌘1 and keypad ⌘1 both narrow the grid).
+- The Russian translation of new strings follows the usual reference-sync step.
+
+## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*
+
+- [ ] Every new source file will carry the AGPL-3.0-only SPDX header (two lines, see CONTRIBUTING.md)
+- [x] No new dependency
+- [x] Audio-thread impact considered: managed-only UI / input change; nothing reaches the audio thread
+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7) — no C ABI change
+- [ ] Smoke-test impact assessed: no engine change; the palette smoke test (every shortcut listed in Settings → Shortcuts) is extended to the catalog
+- [ ] User-visible change → `CHANGELOG.md` `[Unreleased]` entry, FEATURES.md, user docs (nota-docs) and the Shortcuts list (nota-shortcuts)
+- [ ] UI change → follows `DESIGN.md` (Studio design language)
diff --git a/specs/096-custom-shortcuts/tasks.md b/specs/096-custom-shortcuts/tasks.md
new file mode 100644
index 00000000..1af7a64d
--- /dev/null
+++ b/specs/096-custom-shortcuts/tasks.md
@@ -0,0 +1,113 @@
+---
+
+description: "Tasks for 096 custom keyboard shortcuts"
+---
+
+# Tasks: Custom keyboard shortcuts
+
+**Input**: Design documents from `specs/096-custom-shortcuts/`
+
+**Prerequisites**: plan.md, spec.md, research.md, data-model.md, contracts/actions.md,
+contracts/ui-contract.md, quickstart.md
+
+**Tests**: Smoke-test checks are part of the Nota PR gate (constitution IV), so the binding
+logic gets `KeyBindingTests` in `tests/Nota.SmokeTest/`.
+
+**Organization**: grouped by user story. Paths are repo-relative.
+
+## Format: `[ID] [P?] [Story] Description`
+
+- **[P]**: can run in parallel (different files, no dependency on an incomplete task)
+- **[Story]**: US1–US4 from spec.md
+
+---
+
+## Phase 1: Setup
+
+- [X] T001 Add `KeyBindings` (`Dictionary<string, KeyBindingOverride>`) and the `KeyBindingOverride { string? Primary; string? Alternative; }` class ("null = default, \"\" = unassigned, else glyph text") to `src/managed/Nota.Application/Settings.cs`
+
+---
+
+## Phase 2: Foundational (blocking)
+
+- [X] T002 [P] Create `KeyScope` enum (Global, Arrangement, Notes, Session, PianoRoll, AudioEditor, Devices, Browser, Modular) with `IsWindowLayer` (Global | Arrangement | Notes) in `src/managed/Nota.Application/Input/KeyScope.cs`
+- [X] T003 [P] Create `KeyAction` (Id, Title, Group, Scope, DefaultPrimary, DefaultAlternative, IsMenuCommand, NoMenuKey, Fixed, Aliases) in `src/managed/Nota.Application/Input/KeyAction.cs`
+- [X] T004 Create `KeyActionCatalog.Create()` in `src/managed/Nota.Application/Input/KeyActionCatalog.cs`: import every `CommandCatalog` command (gesture → default, scope from `View`/id per contracts/actions.md, roll.* → PianoRoll, session.insertScene → Session), give the shared actions their defaults (edit.copy ⌘C, edit.cut ⌘X, edit.paste ⌘V, edit.delete ⌫ + alt ⌦, NoMenuKey on copy/cut/paste/delete), add `edit.cancel` (Esc) and every *(new)* action of contracts/actions.md with per-platform defaults; `file.exit` Fixed on macOS
+- [X] T005 [P] Create per-platform `ReservedKeys` (research R5) with `Reason(Shortcut, platform)` in `src/managed/Nota.Application/Input/ReservedKeys.cs`
+- [X] T006 Create `KeyBindings` service in `src/managed/Nota.Application/Input/KeyBindings.cs`: load overrides from settings (skip unknown ids / unparsable glyphs with a log line), effective map, `Current`, `IsEdited`, `Matches`, `Resolve(scope, chord)`, `FindConflicts` (rule R3 incl. default-default exemption), `FindShadows`, `Validate` (reserved / bare modifier), atomic `Apply` (set + Replace), `Reset`, `ResetAll`, `NeedsDecision`, `Changed`, persist via `ISettingsService`
+- [X] T007 [P] Create `KeyTokens` (Avalonia `Key` ⇄ token, keypad digits → digit, `FromKeyEvent(KeyEventArgs) → Shortcut?`, platform modifier mapping) in `src/managed/Nota.App/Input/KeyTokens.cs`; route `ToGesture` through it in `src/managed/Nota.App/Input/ShortcutAvaloniaExtensions.cs`
+- [X] T008 Create the app facade `Keys` (`Is(e, id)`, `Resolve(e, scope)`, `Capturing`, `Bindings`) in `src/managed/Nota.App/Input/Keys.cs`; register and load `KeyBindings` at startup (DI in `src/managed/Nota.App/App.axaml.cs` or where `ISettingsService` is created)
+- [X] T009 [P] Add `KeyBindingTests` in `tests/Nota.SmokeTest/KeyBindingTests.cs` (catalog ids unique, every catalog command present, defaults conflict-free under R3 except default pairs, round trip of overrides, unknown id / junk glyph skipped, reserved keys refused, Replace atomic, Reset rechecks, ResetAll, new-default collision → NeedsDecision) and register it in `tests/Nota.SmokeTest/Program.cs`
+
+**Checkpoint**: catalog and service exist, nothing in the UI uses them yet.
+
+---
+
+## Phase 3: User Story 1 — Rebind a shortcut (P1) 🎯 MVP
+
+**Goal**: every key handler asks the bindings; the Shortcuts page can capture, confirm, clear.
+
+**Independent test**: rebind Split to ⌘T and piano-roll Transpose up to ⌘K, restart, both work; old keys don't.
+
+- [X] T010 [US1] Switch `src/managed/Nota.App/MainWindow.Input.cs` to `Keys.Is`: palette toggle and Space / ⇧Space / Return in the tunnel handler (Session Return → `session.launchSelection`), Tab → `view.cycleDetailTab`, the Esc chain → `edit.cancel`, track keys → shared actions, ⌘⇧A, ⌘A, ⌘R, ⌘., ⌘⇧R, ⌘M, ⌘⇧M, ⌘G/⌘⇧G, ⌘⇧V, ⌘⇧C, ⌘⇧D/⌘⇧I, clipboard, nudge/move (`arr.*`), delete, 0, P, Z X C V (`notes.*`), `GridCommandFor`, the `KeyToPitch` map → `notes.*` actions (KeyUp still releases by physical key); keep every gate and the order
+- [X] T011 [P] [US1] Switch `src/managed/Nota.App/PianoRollView.cs` `OnKeyDown` and `src/managed/Nota.App/PianoRollView.Controllers.cs` to `Keys.Is` (roll.* actions, shared edit.*)
+- [X] T012 [P] [US1] Switch `src/managed/Nota.App/SessionView.cs` `HandleKey` (session.rename, session.insertScene, edit.copyToOtherView, shared edit.*; selection arrows stay fixed)
+- [X] T013 [P] [US1] Switch `src/managed/Nota.App/ModularView.cs` key handler (modular.fit, modular.bypass, edit.duplicate, edit.delete, edit.cancel; Space pan stays fixed)
+- [X] T014 [P] [US1] Switch `src/managed/Nota.App/DeviceChainView.Clipboard.cs` (devices.group/ungroup, shared edit.*, edit.cancel) and the Esc paths of rack cards / audio clip editor reached from MainWindow
+- [X] T015 [P] [US1] Switch `src/managed/Nota.App/BrowserView.Files.cs` (browser.back/forward/up/editPath incl. off-macOS alternatives; Return stays fixed)
+- [X] T016 [US1] Menu: `src/managed/Nota.App/MainWindow.MenuKeys.cs` takes gestures from `KeyBindings` (skip NoMenuKey), re-applies them and rebuilds `_menuShortcuts` on `Changed`; `HandleFloatingKeyDown` undo/redo/grid via `Keys.Is`
+- [X] T017 [US1] Replace `ShortcutGroups` with a `ShortcutLayout` (groups of `Action(id)` and `Fixed(key, text)` rows; every catalog action exactly once, mouse/gamepad/navigation rows fixed) in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`; render action rows with key-cap buttons (primary + alternative slot) in `src/managed/Nota.App/PreferencesWindow.cs`
+- [X] T018 [US1] Capture mode in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`: one row at a time, tunnel KeyDown takes every key, `Keys.Capturing` set (MainWindow ignores keys; macOS menu gestures cleared and restored), proposed caps shown, Confirm / Cancel / Clear / Assign Esc, Esc cancels, window deactivation cancels
+- [X] T019 [US1] Add EN strings for new action titles and editor UI to `src/managed/Nota.Application/Localization/en.json`
+- [X] T020 [US1] Update `tests/Nota.SmokeTest/PaletteTests.cs` `RegistryDrift`: every catalog action appears in the Shortcuts layout (instead of the glyph scan)
+
+**Checkpoint**: US1 works end to end.
+
+---
+
+## Phase 4: User Story 2 — Conflicts (P1)
+
+**Independent test**: ⌘D for Transpose up → conflict names Duplicate → Replace; ⇧F for Nudge left → accepted with a note; ⌘Q refused.
+
+- [X] T021 [US2] Conflict line in capture (`FindConflicts`: "⌘D is used by Duplicate (Global)", Replace / Cancel, Confirm hidden) and the shadow note (`FindShadows`) in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`
+- [X] T022 [US2] Reserved / incomplete feedback (`Validate`) in the capture field in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`
+
+---
+
+## Phase 5: User Story 3 — Edited mark, filter, reset (P2)
+
+**Independent test**: edit three, Edited only shows three; reset one; Reset all → none.
+
+- [X] T023 [US3] Edited mark (accent dot), "default ⌘E" caps, ↺ Reset per row (conflict check first) in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`
+- [X] T024 [US3] Header: "Edited only" toggle, "Reset all to defaults…" with confirmation dialog, "Needs a decision" group; filter matches titles, aliases, group and current keys in glyph and spelled forms ("cmd t", "ctrl+t") in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`
+
+---
+
+## Phase 6: User Story 4 — Note map (P3)
+
+**Independent test**: notes.c → Q, Q plays C4; A doesn't.
+
+- [X] T025 [US4] Lay out the 13 note rows + octave / velocity rows in their own group; confirm Notes-scope conflicts against window-layer keys in `src/managed/Nota.App/PreferencesWindow.Shortcuts.cs`
+
+---
+
+## Phase 7: Polish & cross-cutting
+
+- [X] T026 [P] Tooltips (the snap chip's ⌘1–⌘5 line stays static text — follow-up with #60): `KeyTips.Set(control, text, id)` swaps the default glyph for the current key and re-applies on `Changed` in `src/managed/Nota.App/Input/Keys.cs`; use it in `src/managed/Nota.App/MainWindow.MenuKeys.cs` (record, loop record, metronome, maximize, automation) and the snap chip / loop tips
+- [X] T027 [P] Palette hints: current key from `KeyBindings` in `src/managed/Nota.Presentation/PaletteProviders.cs`; refresh the index on `Changed`
+- [X] T028 [P] `CHANGELOG.md` `[Unreleased]` entry and `FEATURES.md` (nota-features skill)
+- [X] T029 User docs (nota-daw/nota-docs#99): shortcuts page EN + RU in `../nota-docs` and its `scripts/shortcuts.mjs` reading the new layout (nota-docs skill; separate nota-docs PR)
+- [ ] T030 `scripts/build.sh` green; walk quickstart.md in the app (macOS) with `NOTA_DATA_DIR=/tmp/n096data`, screenshots of the editor
+
+---
+
+## Dependencies & order
+
+- T001 → T002–T009 → US1 (T010–T020) → US2 / US3 / US4 (editor, any order) → Polish.
+- T010–T015 touch different files and can run in parallel after T008.
+- US2–US4 extend the same editor file, so run them in sequence.
+
+## Implementation strategy
+
+MVP = Phases 1–3 (rebind works, defaults unchanged). Conflicts (US2) must land in the same
+PR before release — without them US1 can break keys. Then US3, US4, polish.
diff --git a/src/managed/Nota.App/App.axaml.cs b/src/managed/Nota.App/App.axaml.cs
index 3673a940..a39cdf14 100644
--- a/src/managed/Nota.App/App.axaml.cs
+++ b/src/managed/Nota.App/App.axaml.cs
@@ -108,6 +108,11 @@ public partial class App : Avalonia.Application
// exists — and before the themes, whose load problems are interface text (spec 087):
// the language is fixed for the run, so those texts are built once, in it.
InstallLanguage(Services.GetRequiredService<ISettingsService>().Current, log);
+ // Keyboard shortcuts (specs/096): the defaults with the user's keys on top. After the
+ // language, as the actions' titles are interface text.
+ var keySettings = Services.GetRequiredService<ISettingsService>();
+ Nota.Application.Input.KeyBindings.Instance = new Nota.Application.Input.KeyBindings(
+ Nota.Application.Input.KeyActionCatalog.Create(), keySettings.Current, keySettings.Save, warn: m => log.Warn(m));
// Colour theme (Preferences → Appearance), applied before the first window paints so
// nothing flashes one theme on the way to another. Old Dark / Light / System
// settings resolve onto the Studio themes (Appearance.Resolve).
diff --git a/src/managed/Nota.App/BrowserView.Files.cs b/src/managed/Nota.App/BrowserView.Files.cs
index d4cd3ff0..e6a578a5 100644
--- a/src/managed/Nota.App/BrowserView.Files.cs
+++ b/src/managed/Nota.App/BrowserView.Files.cs
@@ -13,6 +13,7 @@ using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
+using Nota.App.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Avalonia.Layout;
@@ -317,14 +318,15 @@ public sealed partial class BrowserView
if (paths.Count > 0) Say(SampleFolderUi.AddAll(_settings, paths));
}
- // ⌘[ ⌘] ⌘↑ (Ctrl elsewhere, where Alt+Left / Right / Up work too) walk the browse view;
- // ⌘L / Ctrl+L edits the path.
+ /// <summary>The Files tab has the keyboard — its browse keys win over the window's (specs/096).</summary>
+ public bool FilesFocused => _active == FilesTab && !_collapsed && IsKeyboardFocusWithin && !_search.IsFocused && !_pathBox.IsFocused;
+
+ // Back / forward / up walk the browse view (⌘[ ⌘] ⌘↑ by default, Ctrl elsewhere, where
+ // Alt+Left / Right / Up work too); Edit path (⌘L) types a path. Bindings since specs/096.
private void OnFilesKey(object? sender, KeyEventArgs e)
{
- if (_vm is null || _active != FilesTab || _collapsed || _search.IsFocused || _pathBox.IsFocused) return;
- bool mac = OperatingSystem.IsMacOS();
- var cmd = mac ? KeyModifiers.Meta : KeyModifiers.Control;
- if (e.KeyModifiers == cmd && e.Key == Key.L)
+ if (_vm is null || Keys.Capturing || _active != FilesTab || _collapsed || _search.IsFocused || _pathBox.IsFocused) return;
+ if (Keys.Owns(e, "browser.editPath"))
{
if (!BrowseOn) { SetBrowseMode(true); }
BeginPathEdit();
@@ -332,7 +334,7 @@ public sealed partial class BrowserView
return;
}
if (!BrowseOn) return;
- // Enter opens the selected folder (or drive) of the browse view.
+ // Enter opens the selected folder (or drive) of the browse view — a fixed list key.
if (e.Key is Key.Enter or Key.Return && e.KeyModifiers == KeyModifiers.None
&& _pages[FilesTab].SelectedItem is BrowserItem { Kind: BrowserItemKind.Folder } folder)
{
@@ -340,14 +342,13 @@ public sealed partial class BrowserView
e.Handled = true;
return;
}
- bool alt = !mac && e.KeyModifiers == KeyModifiers.Alt;
- bool back = e.KeyModifiers == cmd && e.Key == Key.OemOpenBrackets || alt && e.Key == Key.Left;
- bool fwd = e.KeyModifiers == cmd && e.Key == Key.OemCloseBrackets || alt && e.Key == Key.Right;
- bool up = e.KeyModifiers == cmd && e.Key == Key.Up || alt && e.Key == Key.Up;
- if (back) _vm.Browse.GoBack();
- else if (fwd) _vm.Browse.GoForward();
- else if (up) _vm.Browse.Up();
- else return;
+ switch (Keys.OwnedBy(e, "browser.back", "browser.forward", "browser.up"))
+ {
+ case "browser.back": _vm.Browse.GoBack(); break;
+ case "browser.forward": _vm.Browse.GoForward(); break;
+ case "browser.up": _vm.Browse.Up(); break;
+ default: return;
+ }
e.Handled = true;
}
diff --git a/src/managed/Nota.App/DeviceChainView.Clipboard.cs b/src/managed/Nota.App/DeviceChainView.Clipboard.cs
index 31bdf756..a7a01460 100644
--- a/src/managed/Nota.App/DeviceChainView.Clipboard.cs
+++ b/src/managed/Nota.App/DeviceChainView.Clipboard.cs
@@ -13,6 +13,7 @@ using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
+using Nota.App.Input;
using Avalonia.Media;
using Nota.Application;
using Nota.Infrastructure;
@@ -465,29 +466,35 @@ public sealed partial class DeviceChainView
protected override void OnKeyDown(KeyEventArgs e)
{
- bool mod = (e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control)) != 0;
- if (mod && e.Key == Key.G && (e.KeyModifiers & KeyModifiers.Alt) == 0)
+ if (Keys.Capturing) return;
+ // Bindings (specs/096): group / ungroup into a rack, and the shared editing actions,
+ // which act on the selected devices while the chain has focus.
+ if (Keys.OwnedBy(e, "devices.group", "devices.ungroup") is { } group)
{
- if ((e.KeyModifiers & KeyModifiers.Shift) != 0) UngroupSelectedDevice(); else GroupSelectedDevice();
+ if (group == "devices.ungroup") UngroupSelectedDevice(); else GroupSelectedDevice();
e.Handled = true; return;
}
+ var edit = Keys.OwnedBy(e, "edit.copy", "edit.cut", "edit.paste", "edit.duplicate", "edit.delete");
// A selected rack chain device takes the clipboard keys (specs/042).
- if (_rackSel != null && _rackCmds is { } rc)
+ if (edit is not null && _rackSel != null && _rackCmds is { } rc)
{
- Action? run = mod ? e.Key switch { Key.C => rc.Copy, Key.X => rc.Cut, Key.V => rc.Paste, Key.D => rc.Duplicate, _ => null }
- : e.Key is Key.Delete or Key.Back ? rc.Delete : null;
+ Action? run = edit switch
+ {
+ "edit.copy" => rc.Copy, "edit.cut" => rc.Cut, "edit.paste" => rc.Paste, "edit.duplicate" => rc.Duplicate, _ => rc.Delete,
+ };
if (run != null) { run(); e.Handled = true; return; }
}
- if (mod && e.Key == Key.C && HasDeviceSelection) { CopySelectedDevice(); e.Handled = true; return; }
- if (mod && e.Key == Key.X && HasDeviceSelection) { CutSelectedDevice(); e.Handled = true; return; }
- if (mod && e.Key == Key.V && CanPaste) { PasteDevice(); e.Handled = true; return; }
- if (mod && e.Key == Key.D && HasEffectSelection) { DuplicateSelectedDevice(); e.Handled = true; return; }
- if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && HasDeviceSelection) { DeleteSelectedDevice(); e.Handled = true; return; }
- // Esc with the XL device selected (a click on the panel's header or its placeholder
+ if (edit == "edit.copy" && HasDeviceSelection) { CopySelectedDevice(); e.Handled = true; return; }
+ if (edit == "edit.cut" && HasDeviceSelection) { CutSelectedDevice(); e.Handled = true; return; }
+ if (edit == "edit.paste" && CanPaste) { PasteDevice(); e.Handled = true; return; }
+ if (edit == "edit.duplicate" && HasEffectSelection) { DuplicateSelectedDevice(); e.Handled = true; return; }
+ if (edit == "edit.delete" && HasDeviceSelection) { DeleteSelectedDevice(); e.Handled = true; return; }
+ // Cancel with the XL device selected (a click on the panel's header or its placeholder
// selects it and focuses the chain) closes the panel, as Esc inside the panel does.
- if (!mod && e.Key == Key.Escape && _xlIndex >= 0 && SingleSelection is { Section: DeviceSection.Audio } xs && xs.Index == _xlIndex)
+ bool cancel = Keys.Owns(e, "edit.cancel");
+ if (cancel && _xlIndex >= 0 && SingleSelection is { Section: DeviceSection.Audio } xs && xs.Index == _xlIndex)
{ CloseXl(_xlIndex); e.Handled = true; return; }
- if (!mod && e.Key == Key.Escape && HasDeviceSelection) { ClearDeviceSelection(); Rebuild(); e.Handled = true; return; }
+ if (cancel && HasDeviceSelection) { ClearDeviceSelection(); Rebuild(); e.Handled = true; return; }
base.OnKeyDown(e);
}
diff --git a/src/managed/Nota.App/DeviceChainView.Xl.cs b/src/managed/Nota.App/DeviceChainView.Xl.cs
index 42c218f4..c35c8071 100644
--- a/src/managed/Nota.App/DeviceChainView.Xl.cs
+++ b/src/managed/Nota.App/DeviceChainView.Xl.cs
@@ -142,10 +142,10 @@ public sealed partial class DeviceChainView
Bypassed: _engine.DeviceBypassed(_trackId, index), Bypassable: true, CanMove: true, CanDelete: false, PresetKind: kind,
IsInstrument: false, Width: double.NaN, Kind: ChainKind.Effect, HeaderExtra: extras, Height: double.NaN, Xl: true);
var card = BuildCardShell(spec, strategy.FullBleed ? body : new Border { Padding = new Thickness(NotaSpace.DeviceInset), Child = body });
- // Esc in the panel (a text box that takes it keeps it) closes it.
+ // Cancel (Esc) in the panel (a text box that takes it keeps it) closes it.
card.KeyDown += (_, e) =>
{
- if (e.Handled || e.Key != Key.Escape) return;
+ if (e.Handled || !Nota.App.Input.Keys.Is(e, "edit.cancel")) return;
e.Handled = true;
CloseXl(index);
};
diff --git a/src/managed/Nota.App/Input/KeyTokens.cs b/src/managed/Nota.App/Input/KeyTokens.cs
new file mode 100644
index 00000000..a024e00a
--- /dev/null
+++ b/src/managed/Nota.App/Input/KeyTokens.cs
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Avalonia keys ⇄ the key tokens bindings are stored in (specs/096, research R4): "A", "7",
+// "F2", "Space", "Esc", "⌫", "←", "[" … Keypad digits read as the digit (⌘1 and keypad ⌘1 both
+// narrow the grid, as before). A pressed key becomes a Shortcut here, with ⌘ = Cmd on macOS
+// and Ctrl elsewhere — the one place that mapping lives.
+
+using System;
+using System.Collections.Generic;
+using Avalonia.Input;
+using Nota.Application.Input;
+
+namespace Nota.App.Input;
+
+public static class KeyTokens
+{
+ private static readonly Dictionary<Key, string> Named = new()
+ {
+ [Key.Space] = "Space", [Key.Return] = "Return", [Key.Tab] = "Tab", [Key.Escape] = "Esc",
+ [Key.Back] = "⌫", [Key.Delete] = "⌦", [Key.Left] = "←", [Key.Right] = "→", [Key.Up] = "↑", [Key.Down] = "↓",
+ [Key.PageUp] = "PgUp", [Key.PageDown] = "PgDn", [Key.Home] = "Home", [Key.End] = "End",
+ [Key.OemComma] = ",", [Key.OemPeriod] = ".", [Key.OemQuestion] = "/", [Key.OemSemicolon] = ";",
+ [Key.OemQuotes] = "'", [Key.OemOpenBrackets] = "[", [Key.OemCloseBrackets] = "]", [Key.OemPipe] = "\\",
+ [Key.OemBackslash] = "\\", [Key.OemMinus] = "-", [Key.OemPlus] = "=", [Key.OemTilde] = "`",
+ };
+
+ private static readonly Dictionary<string, Key> Reverse = BuildReverse();
+
+ private static Dictionary<string, Key> BuildReverse()
+ {
+ var r = new Dictionary<string, Key>(StringComparer.Ordinal);
+ foreach (var (k, t) in Named) r.TryAdd(t, k); // OemPipe wins over OemBackslash for "\"
+ return r;
+ }
+
+ /// <summary>The token for a key, or null for a modifier or a key bindings don't use.</summary>
+ public static string? Token(Key key)
+ {
+ if (key is >= Key.A and <= Key.Z) return ((char)('A' + (key - Key.A))).ToString();
+ if (key is >= Key.D0 and <= Key.D9) return ((char)('0' + (key - Key.D0))).ToString();
+ if (key is >= Key.NumPad0 and <= Key.NumPad9) return ((char)('0' + (key - Key.NumPad0))).ToString();
+ if (key is >= Key.F1 and <= Key.F24) return "F" + (1 + (key - Key.F1));
+ return Named.GetValueOrDefault(key);
+ }
+
+ /// <summary>The Avalonia key for a token (the main-row digit for "0"–"9").</summary>
+ public static Key ToKey(string token)
+ {
+ if (token.Length == 1 && token[0] is >= 'A' and <= 'Z') return Key.A + (token[0] - 'A');
+ if (token.Length == 1 && token[0] is >= '0' and <= '9') return Key.D0 + (token[0] - '0');
+ if (token.Length is 2 or 3 && token[0] == 'F' && int.TryParse(token[1..], out int f) && f is >= 1 and <= 24) return Key.F1 + (f - 1);
+ if (Reverse.TryGetValue(token, out var k)) return k;
+ if (token == "Delete") return Key.Back; // older glyph text
+ return Enum.TryParse<Key>(token, ignoreCase: true, out var parsed) ? parsed : Key.None;
+ }
+
+ public static bool IsModifierKey(Key k) => k is Key.LeftShift or Key.RightShift or Key.LeftCtrl or Key.RightCtrl
+ or Key.LeftAlt or Key.RightAlt or Key.LWin or Key.RWin or Key.System or Key.CapsLock;
+
+ /// <summary>The Win / Super key is held (Windows / Linux) — the system's, never Nota's.</summary>
+ public static bool HasSystemKey(KeyModifiers m) => !OperatingSystem.IsMacOS() && (m & KeyModifiers.Meta) != 0;
+
+ /// <summary>The pressed key as a binding chord, or null (a bare modifier, an unused key, or
+ /// the Win / Super key held).</summary>
+ public static Shortcut? Chord(KeyEventArgs e) => Chord(e.Key, e.KeyModifiers, OperatingSystem.IsMacOS());
+
+ public static Shortcut? Chord(Key key, KeyModifiers m, bool mac)
+ {
+ if (IsModifierKey(key) || Token(key) is not { } token) return null;
+ var mods = ShortcutModifiers.None;
+ if (mac)
+ {
+ if ((m & KeyModifiers.Meta) != 0) mods |= ShortcutModifiers.Primary;
+ if ((m & KeyModifiers.Control) != 0) mods |= ShortcutModifiers.Ctrl;
+ }
+ else
+ {
+ if ((m & KeyModifiers.Meta) != 0) return null;
+ if ((m & KeyModifiers.Control) != 0) mods |= ShortcutModifiers.Primary;
+ }
+ if ((m & KeyModifiers.Alt) != 0) mods |= ShortcutModifiers.Alt;
+ if ((m & KeyModifiers.Shift) != 0) mods |= ShortcutModifiers.Shift;
+ return new Shortcut(mods, token);
+ }
+}
diff --git a/src/managed/Nota.App/Input/Keys.cs b/src/managed/Nota.App/Input/Keys.cs
new file mode 100644
index 00000000..e6160446
--- /dev/null
+++ b/src/managed/Nota.App/Input/Keys.cs
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// What key handlers ask (specs/096): "is this press action X?" against the user's bindings,
+// instead of comparing Key and KeyModifiers by hand. The handlers keep their own focus gates
+// and order; only the comparison moved here. Also the capture latch the Shortcuts editor
+// holds while it records a key, and tooltips that name a key and follow it when it changes.
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Nota.Application;
+using Nota.Application.Input;
+
+namespace Nota.App.Input;
+
+public static class Keys
+{
+ private static KeyBindings? _fallback;
+
+ /// <summary>The app's bindings; the shipped defaults where the app didn't create any
+ /// (headless harnesses, tests).</summary>
+ public static KeyBindings Bindings =>
+ KeyBindings.Instance ?? (_fallback ??= new KeyBindings(KeyActionCatalog.Create(), new Settings()));
+
+ /// <summary>The Shortcuts editor is recording a key: no window runs a shortcut meanwhile.</summary>
+ public static bool Capturing { get; set; }
+
+ // The press a focused view last recognised as one of its own actions — whether or not it
+ // then had anything to act on (⇧↑ with no notes selected). MainWindow's command fallback
+ // leaves such a press alone. Window-level checks (transport, track headers) don't claim: a
+ // key they pass on stays available to the command it is bound to.
+ private static KeyEventArgs? _claimed;
+
+ /// <summary>True when a focused view on this press's route owned it.</summary>
+ public static bool Claimed(KeyEventArgs e) => ReferenceEquals(_claimed, e);
+
+ /// <summary>True when the press is one of action <paramref name="id"/>'s keys.</summary>
+ public static bool Is(KeyEventArgs e, string id) => KeyTokens.Chord(e) is { } c && Bindings.Matches(id, c);
+
+ /// <summary>True when the press is any of the actions' keys.</summary>
+ public static bool IsAny(KeyEventArgs e, params string[] ids) => Which(e, ids) is not null;
+
+ /// <summary>The first of <paramref name="ids"/> the press belongs to, or null.</summary>
+ public static string? Which(KeyEventArgs e, params string[] ids)
+ {
+ if (KeyTokens.Chord(e) is not { } c) return null;
+ foreach (var id in ids) if (Bindings.Matches(id, c)) return id;
+ return null;
+ }
+
+ /// <summary>As <see cref="Is"/>, for a focused view that owns the key: a match claims the press.</summary>
+ public static bool Owns(KeyEventArgs e, string id)
+ {
+ if (!Is(e, id)) return false;
+ _claimed = e;
+ return true;
+ }
+
+ /// <summary>As <see cref="Which"/>, for a focused view that owns the keys: a match claims the press.</summary>
+ public static string? OwnedBy(KeyEventArgs e, params string[] ids)
+ {
+ if (Which(e, ids) is not { } id) return null;
+ _claimed = e;
+ return id;
+ }
+
+ /// <summary>The note-map action the press plays, or null.</summary>
+ public static int NoteIndex(KeyEventArgs e)
+ {
+ if (KeyTokens.Chord(e) is not { } c) return -1;
+ var notes = KeyActionCatalog.NoteKeys;
+ for (int i = 0; i < notes.Length; i++) if (Bindings.Matches(notes[i].Id, c)) return i;
+ return -1;
+ }
+
+ // ---- tooltips that name a key (#60, FR-022) ------------------------------------------
+
+ private static readonly ConditionalWeakTable<Control, Tip> Tips = new();
+ private static readonly List<WeakReference<Control>> TipControls = new();
+ private static bool _listening;
+
+ private sealed record Tip(string Text, string Id);
+
+ /// <summary>Sets a tooltip whose text names action <paramref name="id"/>'s default key
+ /// ("Record (⌘R)"); the key follows the user's binding and is spelled for this platform.</summary>
+ public static void SetTip(Control c, string text, string id)
+ {
+ if (!Tips.TryGetValue(c, out _)) TipControls.Add(new WeakReference<Control>(c));
+ Tips.AddOrUpdate(c, new Tip(text, id));
+ ToolTip.SetTip(c, TipText(text, id));
+ if (_listening) return;
+ _listening = true;
+ Bindings.Changed += RefreshTips;
+ }
+
+ /// <summary>The text with the action's default key swapped for its current key (dropped,
+ /// with its brackets, when the action has none), spelled for this platform.</summary>
+ public static string TipText(string text, string id)
+ {
+ if (Bindings.Get(id) is { } a && a.DefaultPrimary is { } d)
+ {
+ string def = d.ToGlyphs();
+ if (Bindings.Shown(id) is { } now) text = text.Replace(def, now.ToGlyphs(), StringComparison.Ordinal);
+ else text = text.Replace(" (" + def + ")", "", StringComparison.Ordinal).Replace(" (" + def, " (", StringComparison.Ordinal)
+ .Replace(def, "", StringComparison.Ordinal);
+ }
+ return Shortcut.SpellText(text);
+ }
+
+ private static void RefreshTips()
+ {
+ TipControls.RemoveAll(w => !w.TryGetTarget(out _));
+ foreach (var w in TipControls)
+ if (w.TryGetTarget(out var c) && Tips.TryGetValue(c, out var t))
+ ToolTip.SetTip(c, TipText(t.Text, t.Id));
+ }
+}
diff --git a/src/managed/Nota.App/Input/ShortcutAvaloniaExtensions.cs b/src/managed/Nota.App/Input/ShortcutAvaloniaExtensions.cs
index 6ce50189..c4700c5c 100644
--- a/src/managed/Nota.App/Input/ShortcutAvaloniaExtensions.cs
+++ b/src/managed/Nota.App/Input/ShortcutAvaloniaExtensions.cs
@@ -29,14 +29,7 @@ public static class ShortcutAvaloniaExtensions
if ((s.Modifiers & ShortcutModifiers.Ctrl) != 0)
mods |= KeyModifiers.Control;
- Key key = s.Key switch
- {
- "," => Key.OemComma,
- "." => Key.OemPeriod,
- "Esc" => Key.Escape,
- _ when s.Key.Length == 1 && char.IsDigit(s.Key[0]) => Key.D0 + (s.Key[0] - '0'),
- _ => Enum.TryParse<Key>(s.Key, ignoreCase: true, out var parsed) ? parsed : Key.None,
- };
+ Key key = KeyTokens.ToKey(s.Key);
return key == Key.None ? null : new KeyGesture(key, mods);
}
diff --git a/src/managed/Nota.App/MainWindow.Detail.cs b/src/managed/Nota.App/MainWindow.Detail.cs
index f1a33316..4974266c 100644
--- a/src/managed/Nota.App/MainWindow.Detail.cs
+++ b/src/managed/Nota.App/MainWindow.Detail.cs
@@ -1245,7 +1245,7 @@ public partial class MainWindow
_detailRow.Height = on ? new GridLength(1, GridUnitType.Star) : new GridLength(_detailWanted > 120 ? _detailWanted : _detailDefault);
DetailSplitter.IsVisible = !on;
DetailMaximizeGlyph.Kind = on ? GlyphKind.Shrink : GlyphKind.Expand;
- ToolTip.SetTip(DetailMaximizeBtn, MenuKit.Keys(on ? Loc.T("main.detail.back_to_the_split_f") : Loc.T("main.fill_the_window_with_the")));
+ Nota.App.Input.Keys.SetTip(DetailMaximizeBtn, on ? Loc.T("main.detail.back_to_the_split_f") : Loc.T("main.fill_the_window_with_the"), "view.maximizeDetail");
if (MenuItemFor("view.maximizeDetail") is { } mi) mi.IsChecked = on;
LayoutBottomPanels();
}
diff --git a/src/managed/Nota.App/MainWindow.Input.cs b/src/managed/Nota.App/MainWindow.Input.cs
index fc025c2d..b6884a53 100644
--- a/src/managed/Nota.App/MainWindow.Input.cs
+++ b/src/managed/Nota.App/MainWindow.Input.cs
@@ -19,21 +19,18 @@ using Microsoft.Extensions.DependencyInjection;
using Nota.Application;
using Nota.Presentation;
using Nota.Application.Localization;
+using Nota.Application.Input;
+using Nota.App.Input;
+using Nota.Application.Palette;
namespace Nota.App;
public partial class MainWindow
{
- // Computer-keyboard piano mapping, classic typing-keyboard layout: the A-row is the
- // white keys (A=C4=60 … K=C5) and the Q-row the black keys (W E T Y U). Z/X shift the
- // octave and C/V the velocity (see the handlers below); Automation mode moved to ⌘⇧A.
- // These are BASE pitches at octave 0 — _typingOctave*12 is added when a note plays.
- private static readonly Dictionary<Key, int> KeyToPitch = new()
- {
- [Key.A] = 60, [Key.W] = 61, [Key.S] = 62, [Key.E] = 63, [Key.D] = 64,
- [Key.F] = 65, [Key.T] = 66, [Key.G] = 67, [Key.Y] = 68, [Key.H] = 69,
- [Key.U] = 70, [Key.J] = 71, [Key.K] = 72,
- };
+ // Computer-keyboard piano: the note-map actions (notes.c … notes.c2, specs/096) play C4 up
+ // to C5 — by default the A-row is the white keys and the Q-row the black keys. Z/X shift
+ // the octave and C/V the velocity. Pitches are C4-based; _typingOctave*12 is added.
+ private const int TypingBasePitch = 60;
// Tunnel-phase handler for the two transport keys that a focused control would
// otherwise steal (Space activates a focused Button/CheckBox/ToggleButton; Space/Enter
@@ -43,11 +40,12 @@ public partial class MainWindow
// spaces/newlines still type. Everything else stays in the bubble-phase OnKeyDown.
private void OnGlobalTransportKey(object? sender, KeyEventArgs e)
{
- if (_vm is null) return;
+ if (_vm is null || Keys.Capturing) return; // the Shortcuts editor is recording a key
// ⌘⇧P / Ctrl+Shift+P: the command palette, from any window and any focus — a text
// field included, as the chord types nothing (CP-1). Again closes it.
- if (e.Key == Key.P && ArrangementView.IsPrimaryDown(e.KeyModifiers)
- && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0)
+ // A palette key that types something (a bare or ⇧ key) leaves text fields alone.
+ if (Keys.Is(e, CommandCatalog.Palette)
+ && (KeyTokens.Chord(e) is { IsChord: true } || e.Source is not (TextBox or NumericUpDown)))
{
TogglePalette(e.Source is Avalonia.Visual v ? TopLevel.GetTopLevel(v) as Window : null);
e.Handled = true;
@@ -55,27 +53,46 @@ public partial class MainWindow
}
if (_vm.SuspendEnginePolling || PaletteOpen) return; // the palette has the keyboard
if (e.Source is TextBox || e.Source is NumericUpDown) return;
- if ((e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control | KeyModifiers.Alt)) != 0) return;
- if (e.Key == Key.Space)
+ if (Keys.Is(e, "session.launchSelection") && SessionFocused)
{
- // ⇧Space pauses instead: the playhead stays where it stopped (#51).
- _commands.Run((e.KeyModifiers & KeyModifiers.Shift) != 0 ? "transport.playPause" : "transport.playStop");
+ // In the Session grid Return launches the selected slot or scene (design 1a).
+ _session!.LaunchSelection();
e.Handled = true;
+ return;
}
- else if (e.Key == Key.Return && Browser.TakesReturn(e.Source))
+ var transport = Keys.Which(e, "transport.playStop", "transport.playPause", "transport.stop");
+ if (transport is null) return;
+ // A focused view that binds this key itself wins (specs/096 R3): leave it to the view.
+ if (KeyTokens.Chord(e) is { } chord && ScopeOf(e.Source) is { } scope && Keys.Bindings.Resolve(scope, chord) is not null) return;
+ if (transport == "transport.stop" && Browser.TakesReturn(e.Source))
{
// A Modular node selected in the browser: Return adds it (specs/095), so leave the
// key to the list rather than stopping the transport.
+ return;
}
- else if (e.Key == Key.Return)
- {
- // In the Session grid Return launches the selected slot or scene (design 1a);
- // everywhere else it stops (second press returns to 1.1).
- if (SessionFocused) _session!.LaunchSelection();
- else _commands.Run("transport.stop");
- e.Handled = true;
- }
+ // Space = Play/Stop, ⇧Space pauses (the playhead stays, #51), Return = Stop (second
+ // press returns to 1.1).
+ _commands.Run(transport);
+ e.Handled = true;
+ }
+
+ // The focus scope the key came from (specs/096): the view that handles its own keys
+ // before the window does, or null for the window itself.
+ private KeyScope? ScopeOf(object? source)
+ {
+ if (source is not Visual v) return null;
+ foreach (var a in v.GetSelfAndVisualAncestors())
+ switch (a)
+ {
+ case SessionView: return KeyScope.Session;
+ case PianoRollView: return _editorRoll is { GridFocused: true } ? KeyScope.PianoRoll : null;
+ case ModularView: return KeyScope.Modular;
+ case DeviceChainView: return KeyScope.Devices;
+ case BrowserView b: return b.FilesFocused ? KeyScope.Browser : null;
+ case AudioClipEditorView: return KeyScope.AudioEditor;
+ }
+ return null;
}
// A text field keeps the keyboard until focus moves elsewhere — but the arrangement, piano
@@ -107,18 +124,17 @@ public partial class MainWindow
internal void HandleTransportKeyTunnel(KeyEventArgs e) => OnGlobalTransportKey(this, e);
internal void HandleFloatingKeyDown(KeyEventArgs e)
{
- bool meta = (e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control)) != 0;
- if (meta && e.Key == Key.Z && (e.KeyModifiers & KeyModifiers.Alt) == 0)
+ if (Keys.Capturing) return;
+ if (Keys.Which(e, "edit.undo", "edit.redo") is { } undo)
{
- if ((e.KeyModifiers & KeyModifiers.Shift) != 0) _commands.Run("edit.redo");
- else _commands.Run("edit.undo");
+ _commands.Run(undo);
e.Handled = true;
return;
}
// The floating window has no native menu, so ⌘1–⌘5 (the grid) never arrive as menu key
// equivalents there: run them here. Windows / Linux stop here too, so their in-window
// menu path below doesn't run them a second time.
- if (meta && (e.KeyModifiers & (KeyModifiers.Alt | KeyModifiers.Shift)) == 0 && GridCommandFor(e.Key) is { } grid)
+ if (Keys.Which(e, GridCommands) is { } grid)
{
_commands.Run(grid);
e.Handled = true;
@@ -127,15 +143,7 @@ public partial class MainWindow
HandleKeyDown(e);
}
- private static string? GridCommandFor(Key key) => key switch
- {
- Key.D1 or Key.NumPad1 => "grid.narrower",
- Key.D2 or Key.NumPad2 => "grid.wider",
- Key.D3 or Key.NumPad3 => "grid.triplets",
- Key.D4 or Key.NumPad4 => "grid.snap",
- Key.D5 or Key.NumPad5 => "grid.adaptive",
- _ => null,
- };
+ private static readonly string[] GridCommands = { "grid.narrower", "grid.wider", "grid.triplets", "grid.snap", "grid.adaptive" };
// --- live play from the computer keyboard + basic shortcuts (M7-3) ---
protected override void OnKeyDown(KeyEventArgs e) => HandleKeyDown(e);
@@ -143,207 +151,174 @@ public partial class MainWindow
// Shared with the floating detail window (see HandleFloatingKeyDown).
internal void HandleKeyDown(KeyEventArgs e)
{
- if (_vm is null || _vm.SuspendEnginePolling || e.Source is TextBox || e.Source is NumericUpDown) { base.OnKeyDown(e); return; }
+ if (_vm is null || Keys.Capturing || _vm.SuspendEnginePolling || e.Source is TextBox || e.Source is NumericUpDown) { base.OnKeyDown(e); return; }
- // ⌘/⌃/⌥ combos are shortcuts (menu accelerators handle them) — never
- // sound a note. Bare letters still play via the KeyToPitch map below.
- bool mod = (e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control | KeyModifiers.Alt)) != 0;
+ // Every key here is a binding (specs/096): Keys.Is asks the user's keys, so the gates
+ // and the order below are what decides between actions, never a hard-coded key.
- // Tab cycles the detail panel's Devices/Pattern/Clip tabs when it was the last area used.
- if (!mod && e.Key == Key.Tab && DetailPanel.IsVisible && _detailWasLastFocused)
+ // Cycle the detail panel's Devices/Pattern/Clip tabs when it was the last area used.
+ if (Keys.Is(e, "view.cycleDetailTab") && DetailPanel.IsVisible && _detailWasLastFocused)
{
ToggleDetailTab();
e.Handled = true;
return;
}
- // Transport hotkeys: Space = Play/Stop and Return = Stop are handled earlier in the
- // tunnel phase (OnGlobalTransportKey) so a focused control can't steal them. ⌘R =
- // Record; ⌘M = Metronome (below) — also menu accelerators, so on macOS the native
- // menu usually handles them first; de-duped against auto-repeat via _heldKeys.
+ // Transport hotkeys: Play/Stop, Pause and Stop are handled earlier in the tunnel phase
+ // (OnGlobalTransportKey) so a focused control can't steal them. Record, retry take,
+ // loop record mode and the metronome (below) are menu accelerators too, so on macOS the
+ // native menu usually handles them first; de-duped against auto-repeat via _heldKeys.
- // Esc: cancel an in-progress arrangement gesture, else clear the selection (req 1.2.6/2.11).
- // Esc mid-drag of a warp marker / segment tempo in the audio clip editor drops it (#140).
- if (!mod && e.Key == Key.Escape && _audioEditor is { IsEffectivelyVisible: true } audioEd && audioEd.CancelGesture())
+ // Cancel (Esc): an in-progress gesture, else the selection (req 1.2.6/2.11). A warp
+ // marker / segment tempo mid-drag in the audio clip editor drops first (#140).
+ bool cancel = Keys.Is(e, "edit.cancel");
+ if (cancel && _audioEditor is { IsEffectivelyVisible: true } audioEd && audioEd.CancelGesture())
{
e.Handled = true;
return;
}
- // Esc ends macro mapping on a rack card (specs/040) before it touches the arrangement.
- if (!mod && e.Key == Key.Escape && RackCardState.EndAllMapping())
+ // Cancel ends macro mapping on a rack card (specs/040) before it touches the arrangement.
+ if (cancel && RackCardState.EndAllMapping())
{
if (DetailBody.Content is DeviceChainView chain) chain.Refresh();
e.Handled = true;
return;
}
- if (!mod && e.Key == Key.Escape && Timeline.EscapePressed())
+ if (cancel && Timeline.EscapePressed())
{
e.Handled = true;
return;
}
- // Track headers focused (the last click landed in the header column): ⌘A selects every
- // track, ⌘C/X/V/D copy/cut/paste/duplicate the selected tracks, Delete removes them.
- // Anything with nothing to act on falls through to the clip handling below.
+ // Track headers focused (the last click landed in the header column): select all,
+ // copy / cut / paste / duplicate the selected tracks, delete them. Anything with nothing
+ // to act on falls through to the clip handling below.
if (_trackHeadersFocused && Timeline.IsVisible && HandleTrackKey(e))
{
e.Handled = true;
return;
}
- // ⌘/⌃ + ⇧ + A: toggle Automation mode. ⌘/⌃ + A: select all arrangement clips —
- // gated to when the piano-roll grid isn't focused, where ⌘A instead selects all notes.
- if (mod && e.Key == Key.A && (e.KeyModifiers & KeyModifiers.Alt) == 0)
+ if (Keys.Is(e, "view.automation"))
{
- if ((e.KeyModifiers & KeyModifiers.Shift) != 0)
- {
- _commands.Run("view.automation");
- e.Handled = true;
- return;
- }
- if (_editorRoll is not { GridFocused: true } && Timeline.SelectAllClips())
- {
- e.Handled = true;
- return;
- }
- }
- bool plainMod = mod && (e.KeyModifiers & (KeyModifiers.Alt | KeyModifiers.Shift)) == 0;
- if (plainMod && e.Key == Key.R)
- {
- if (_heldKeys.Add(e.Key)) _commands.Run("transport.record");
- e.Handled = true; // an auto-repeat is swallowed, not passed on to the menu
- return;
- }
- // ⌘. / ⌃.: discard the take and record it again (#185). Held down it retries once,
- // not on every auto-repeat.
- if (plainMod && e.Key == Key.OemPeriod)
- {
- if (_heldKeys.Add(e.Key)) _commands.Run("transport.retryTake");
+ _commands.Run("view.automation");
e.Handled = true;
return;
}
- // ⌘⇧R / ⌃⇧R: loop record mode, Overdub ↔ Replace.
- if (mod && e.Key == Key.R && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0)
+ // Select all arrangement clips — not while the piano-roll grid is focused, where it
+ // selects all notes instead.
+ if (Keys.Is(e, "edit.selectAll") && _editorRoll is not { GridFocused: true } && Timeline.SelectAllClips())
{
- if (_heldKeys.Add(e.Key)) _commands.Run("transport.loopRecordMode");
e.Handled = true;
return;
}
- if (plainMod && e.Key == Key.M)
+ // Held down these run once, not on every auto-repeat (the repeat is swallowed, not
+ // passed on to the menu). Retry take: discard the take and record it again (#185).
+ if (Keys.Which(e, "transport.record", "transport.retryTake", "transport.loopRecordMode", "transport.metronome") is { } held)
{
- if (_heldKeys.Add(e.Key)) _commands.Run("transport.metronome");
- e.Handled = true; // an auto-repeat is swallowed, not passed on to the menu
- return;
- }
-
- // ⌘⇧M / ⌃⇧M = show or hide the Mixer, docked or in its window (specs/054).
- if (mod && e.Key == Key.M && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0)
- {
- _commands.Run("view.mixer");
+ if (_heldKeys.Add(e.Key)) _commands.Run(held);
e.Handled = true;
return;
}
- // ⌘/⌃ + G = group the selected tracks; ⌘/⌃ + ⇧ + G = ungroup.
- if (mod && e.Key == Key.G && (e.KeyModifiers & KeyModifiers.Alt) == 0)
+ // Show or hide the Mixer, docked or in its window (specs/054); group / ungroup the
+ // selected tracks.
+ if (Keys.Which(e, "view.mixer", "track.group", "track.ungroup") is { } win)
{
- _commands.Run((e.KeyModifiers & KeyModifiers.Shift) != 0 ? "track.ungroup" : "track.group");
+ _commands.Run(win);
e.Handled = true;
return;
}
- // ⌘⇧V / ⌃⇧V = Paste Bounced Audio: render the last time selection through its track's
- // chain and paste it onto the focused audio track at the playhead (MainWindow.PasteBounced).
- if (e.Key == Key.V && ArrangementView.IsPrimaryDown(e.KeyModifiers)
- && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0
- && _editorRoll is not { GridFocused: true })
+ // Paste Bounced Audio: render the last time selection through its track's chain and
+ // paste it onto the focused audio track at the playhead (MainWindow.PasteBounced).
+ if (Keys.Is(e, "edit.pasteBounced") && _editorRoll is not { GridFocused: true })
{
_commands.Run("edit.pasteBounced");
e.Handled = true;
return;
}
- // ⌘⇧C / ⌃⇧C = Copy to Session (Arrangement) / Copy to Arrangement (Session) — also the
- // Edit menu's accelerator, which gets there first on macOS. The focused Session grid
- // handles the key itself; the piano-roll grid keeps it for its notes.
- if (e.Key == Key.C && ArrangementView.IsPrimaryDown(e.KeyModifiers)
- && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0
- && _editorRoll is not { GridFocused: true })
+ // Copy to Session (Arrangement) / Copy to Arrangement (Session) — also the Edit menu's
+ // accelerator, which gets there first on macOS. The focused Session grid handles the
+ // key itself; the piano-roll grid keeps it for its notes.
+ if (Keys.Is(e, "edit.copyToOtherView") && _editorRoll is not { GridFocused: true })
{
_commands.Run("edit.copyToOtherView");
e.Handled = true;
return;
}
- // ⌘⇧D / ⌃⇧D = Duplicate Time, ⌘⇧I / ⌃⇧I = Insert Silence over the arrangement time
- // selection. On macOS the Edit menu's accelerators get there first.
- if ((e.Key == Key.D || e.Key == Key.I) && !OperatingSystem.IsMacOS()
- && ArrangementView.IsPrimaryDown(e.KeyModifiers)
- && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0
- && Timeline.HasTimeSelection)
+ // Duplicate Time, Insert Silence over the arrangement time selection. On macOS the Edit
+ // menu's accelerators get there first.
+ if (!OperatingSystem.IsMacOS() && Timeline.HasTimeSelection
+ && Keys.Which(e, "edit.duplicateTime", "edit.insertSilence") is { } timeOp)
{
- _commands.Run(e.Key == Key.D ? "edit.duplicateTime" : "edit.insertSilence");
+ _commands.Run(timeOp);
e.Handled = true;
return;
}
- // ⌘/⌃ + C/X/V = copy/cut/paste the selected arrangement clip. Skipped while the
- // piano-roll grid is focused (it copies/pastes notes) and when nothing is
- // actionable, so the event falls through to other handlers.
- if (mod && (e.KeyModifiers & (KeyModifiers.Alt | KeyModifiers.Shift)) == 0
- && _editorRoll is not { GridFocused: true })
+ // Copy / cut / paste the selected arrangement clip. Skipped while the piano-roll grid is
+ // focused (it copies / pastes notes) and when nothing is actionable, so the event falls
+ // through to other handlers.
+ var clip = _editorRoll is not { GridFocused: true } ? Keys.Which(e, "edit.copy", "edit.cut", "edit.paste") : null;
+ if (clip is not null)
{
- // In automation mode a selected time-range takes priority: C/X/V move the
- // envelope, not the clip. Each returns false when there's nothing to act on,
- // so the shortcut falls through to the clip clipboard below.
+ // In automation mode a selected time-range takes priority: the keys move the
+ // envelope, not the clip. Each returns false when there's nothing to act on, so the
+ // shortcut falls through to the clip clipboard below.
if (Timeline.AutomationMode)
{
- if (e.Key == Key.C && Timeline.CopyAutoSelection()) { _vm.StatusText = Loc.T("main.input.copied_automation"); e.Handled = true; return; }
- if (e.Key == Key.X && Timeline.CutAutoSelection()) { _vm.StatusText = Loc.T("main.input.cut_automation"); e.Handled = true; return; }
- if (e.Key == Key.V && Timeline.PasteAuto()) { _vm.StatusText = Loc.T("main.input.pasted_automation"); e.Handled = true; return; }
+ if (clip == "edit.copy" && Timeline.CopyAutoSelection()) { _vm.StatusText = Loc.T("main.input.copied_automation"); e.Handled = true; return; }
+ if (clip == "edit.cut" && Timeline.CutAutoSelection()) { _vm.StatusText = Loc.T("main.input.cut_automation"); e.Handled = true; return; }
+ if (clip == "edit.paste" && Timeline.PasteAuto()) { _vm.StatusText = Loc.T("main.input.pasted_automation"); e.Handled = true; return; }
}
// A time range (Shift+drag) copies / cuts the covered slice; it and a clip selection
// are exclusive, so these return false whenever clips are selected instead.
- if (e.Key == Key.C && Timeline.CopyTimeSelection()) { _vm.StatusText = Loc.T("main.copied_range"); e.Handled = true; return; }
- if (e.Key == Key.X && Timeline.CutTimeSelection()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.cut_range"); e.Handled = true; return; }
- if (e.Key == Key.C && Timeline.CopySelectedClip()) { _vm.StatusText = Loc.T("main.input.copied_clip_s"); e.Handled = true; return; }
- if (e.Key == Key.X && Timeline.CutSelectedClip()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.input.cut_clip_s"); e.Handled = true; return; }
- if (e.Key == Key.V && Timeline.PasteClipboard()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.input.pasted_clip_s"); e.Handled = true; return; }
+ if (clip == "edit.copy" && Timeline.CopyTimeSelection()) { _vm.StatusText = Loc.T("main.copied_range"); e.Handled = true; return; }
+ if (clip == "edit.cut" && Timeline.CutTimeSelection()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.cut_range"); e.Handled = true; return; }
+ if (clip == "edit.copy" && Timeline.CopySelectedClip()) { _vm.StatusText = Loc.T("main.input.copied_clip_s"); e.Handled = true; return; }
+ if (clip == "edit.cut" && Timeline.CutSelectedClip()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.input.cut_clip_s"); e.Handled = true; return; }
+ if (clip == "edit.paste" && Timeline.PasteClipboard()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.input.pasted_clip_s"); e.Handled = true; return; }
}
- // ←/→ nudge the selected arrangement clips by the grid step (⌥: a 64th); ⌥↑/⌥↓ move them
- // to the next track that takes them (#302). Only with clips selected, and not while the
- // piano roll, the detail panel or the floating detail window has the keys.
- if (e.Key is Key.Left or Key.Right or Key.Up or Key.Down && ArrangementShown && !_detailWasLastFocused
- && _detailWindow?.IsActive != true
- && _editorRoll is not { GridFocused: true }
- && (e.KeyModifiers & (KeyModifiers.Control | KeyModifiers.Meta | KeyModifiers.Shift)) == 0)
- {
- bool alt = (e.KeyModifiers & KeyModifiers.Alt) != 0;
- bool done = e.Key is Key.Left or Key.Right
- ? Timeline.NudgeSelectedClips(e.Key == Key.Right ? 1 : -1, fine: alt)
- : alt && Timeline.MoveSelectedClipsToTrack(e.Key == Key.Down ? 1 : -1);
+ // Nudge the selected arrangement clips by the grid step (fine: a 64th); move them to the
+ // next track that takes them (#302). Only with clips selected, and not while the piano
+ // roll, the detail panel or the floating detail window has the keys.
+ if (ArrangementShown && !_detailWasLastFocused && _detailWindow?.IsActive != true && _editorRoll is not { GridFocused: true }
+ && Keys.Which(e, ClipMoveKeys) is { } move)
+ {
+ bool done = move switch
+ {
+ "arr.nudgeLeft" => Timeline.NudgeSelectedClips(-1, fine: false),
+ "arr.nudgeRight" => Timeline.NudgeSelectedClips(1, fine: false),
+ "arr.nudgeFineLeft" => Timeline.NudgeSelectedClips(-1, fine: true),
+ "arr.nudgeFineRight" => Timeline.NudgeSelectedClips(1, fine: true),
+ "arr.moveToTrackUp" => Timeline.MoveSelectedClipsToTrack(-1),
+ _ => Timeline.MoveSelectedClipsToTrack(1),
+ };
if (done) { _session?.Refresh(); e.Handled = true; return; }
}
- // Delete/Backspace = clear the selected automation range (automation mode), else
- // remove the selected arrangement clip. Only consumed when something is actually
- // selected, so the piano roll (which has focus + its own Delete handler) keeps
- // note-deletion.
- if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && Timeline.AutomationMode && Timeline.DeleteAutoSelection())
+ // Delete = clear the selected automation range (automation mode), else remove the
+ // selected arrangement clip. Only consumed when something is actually selected, so the
+ // piano roll (which has focus + its own delete handler) keeps note-deletion.
+ bool delete = Keys.Is(e, "edit.delete");
+ if (delete && Timeline.AutomationMode && Timeline.DeleteAutoSelection())
{
_vm.StatusText = Loc.T("main.input.deleted_automation");
e.Handled = true;
return;
}
- if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && Timeline.DeleteTimeSelection())
+ if (delete && Timeline.DeleteTimeSelection())
{
_session?.Refresh();
_vm.StatusText = Loc.T("main.input.deleted_range");
e.Handled = true;
return;
}
- if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && Timeline.DeleteSelectedClips())
+ if (delete && Timeline.DeleteSelectedClips())
{
_session?.Refresh();
_vm.StatusText = Loc.T("main.deleted_clip_s");
@@ -351,48 +326,52 @@ public partial class MainWindow
return;
}
- // 0 = toggle the selected clip(s) active/inactive (clip deactivate). De-duped
- // against auto-repeat via _heldKeys; skipped while the piano-roll grid is focused.
- if (!mod && (e.Key == Key.D0 || e.Key == Key.NumPad0)
- && _editorRoll is not { GridFocused: true } && _heldKeys.Add(e.Key))
+ // Toggle the selected clip(s) active/inactive (clip deactivate). De-duped against
+ // auto-repeat via _heldKeys; skipped while the piano-roll grid is focused.
+ if (Keys.Is(e, "edit.toggleClipActive") && _editorRoll is not { GridFocused: true } && _heldKeys.Add(e.Key))
{
if (Timeline.ToggleSelectedClipsActive()) { _session?.Refresh(); _vm.StatusText = Loc.T("main.toggled_clip_s"); }
e.Handled = true;
return;
}
- // P: Show playhead (#105) — scroll the arrangement to it, without moving it.
- if (!mod && e.Key == Key.P && (e.KeyModifiers & KeyModifiers.Shift) == 0 && _heldKeys.Add(e.Key))
+ // Show playhead (#105) — scroll the arrangement to it, without moving it.
+ if (Keys.Is(e, "view.showPlayhead") && _heldKeys.Add(e.Key))
{
_commands.Run("view.showPlayhead");
e.Handled = true;
return;
}
- // Z / X: shift the typing-keyboard octave; C / V: nudge the typing velocity.
- // De-duped against auto-repeat so one press = one step; skipped in the piano-roll grid.
- if (!mod && _editorRoll is not { GridFocused: true }
- && (e.Key == Key.Z || e.Key == Key.X || e.Key == Key.C || e.Key == Key.V) && _heldKeys.Add(e.Key))
+ // Shift the typing-keyboard octave; nudge the typing velocity. De-duped against
+ // auto-repeat so one press = one step; skipped in the piano-roll grid.
+ if (_editorRoll is not { GridFocused: true }
+ && Keys.Which(e, "notes.octaveDown", "notes.octaveUp", "notes.velocityDown", "notes.velocityUp") is { } typing
+ && _heldKeys.Add(e.Key))
{
- if (e.Key == Key.Z) ShiftTypingOctave(-1);
- else if (e.Key == Key.X) ShiftTypingOctave(+1);
- else if (e.Key == Key.C) ShiftTypingVelocity(-10);
- else ShiftTypingVelocity(+10);
+ switch (typing)
+ {
+ case "notes.octaveDown": ShiftTypingOctave(-1); break;
+ case "notes.octaveUp": ShiftTypingOctave(+1); break;
+ case "notes.velocityDown": ShiftTypingVelocity(-10); break;
+ default: ShiftTypingVelocity(+10); break;
+ }
e.Handled = true;
return;
}
// Nothing above took it: the menu's shortcuts (Ctrl+S, Ctrl+Z…) on Windows / Linux —
- // plus bare function keys (F11 = full screen), the one modifier-less menu gesture.
- if ((mod || e.Key is >= Key.F1 and <= Key.F12) && TryMenuShortcut(e))
+ // chords and bare function keys (F11 = full screen), the menu gestures — then any other
+ // command key: an alternative key, a bare key the menu can't carry, a palette-only command.
+ if (TryMenuShortcut(e) || TryCommandKey(e))
{
e.Handled = true;
return;
}
- if (!mod && KeyToPitch.TryGetValue(e.Key, out int basePitch) && _heldKeys.Add(e.Key))
+ if (Keys.NoteIndex(e) is int note and >= 0 && _heldKeys.Add(e.Key))
{
- int pitch = Math.Clamp(basePitch + _typingOctave * 12, 0, 127);
+ int pitch = Math.Clamp(TypingBasePitch + note + _typingOctave * 12, 0, 127);
_heldNotePitch[e.Key] = pitch; // release at this exact pitch even if the octave changes
Engine.NoteOn(pitch, _typingVelocity / 127f);
e.Handled = true;
@@ -400,26 +379,46 @@ public partial class MainWindow
else base.OnKeyDown(e);
}
+ // A palette command bound to this key (specs/096) that no handler above and no menu item took:
+ // window-wide commands anywhere, a view's commands while that view has the keyboard.
+ private bool TryCommandKey(KeyEventArgs e)
+ {
+ if (KeyTokens.Chord(e) is not { } chord || Keys.Claimed(e)) return false;
+ var focus = ScopeOf(e.Source);
+ foreach (var a in Keys.Bindings.Actions)
+ {
+ if (!a.IsCommand || !(a.Scope.IsWindowLayer() || a.Scope == focus)) continue;
+ // Copy, cut, paste and delete are always handled by the window and the focused views
+ // above, which know what is selected; their menu handlers act on the clip editor even
+ // when it no longer has focus. (Duplicate and Select all go to theirs: those route by
+ // focus — Session, the piano-roll grid, track headers, the arrangement.)
+ if (a.NoMenuKey) continue;
+ if (!Keys.Bindings.Matches(a.Id, chord) || _commands.Get(a.Id) is not { IsBound: true }) continue;
+ if (_heldKeys.Contains(e.Key)) return true; // one run per press, not per auto-repeat
+ _heldKeys.Add(e.Key);
+ _commands.Run(a.Id);
+ return true;
+ }
+ return false;
+ }
+
+ private static readonly string[] ClipMoveKeys =
+ { "arr.nudgeLeft", "arr.nudgeRight", "arr.nudgeFineLeft", "arr.nudgeFineRight", "arr.moveToTrackUp", "arr.moveToTrackDown" };
+
// Track-header keys (see HandleKeyDown). True when the key acted on tracks.
private bool HandleTrackKey(KeyEventArgs e)
{
if (_vm is null) return false;
- bool extra = (e.KeyModifiers & (KeyModifiers.Alt | KeyModifiers.Shift)) != 0;
- if (ArrangementView.IsPrimaryDown(e.KeyModifiers) && !extra)
+ switch (Keys.Which(e, "edit.selectAll", "edit.copy", "edit.cut", "edit.paste", "edit.duplicate", "edit.delete"))
{
- switch (e.Key)
- {
- case Key.A: return Timeline.SelectAllTracks();
- case Key.C: return Report(Timeline.CopySelectedTracks(), Loc.T("main.copied_track_s"));
- case Key.X: return Report(Timeline.CutSelectedTracks(), Loc.T("main.cut_track_s"));
- case Key.V: return Report(Timeline.PasteTracks(), Loc.T("main.pasted_track_s"));
- // macOS: the Edit menu's ⌘D accelerator gets there first (OnMenuDuplicate).
- case Key.D when !OperatingSystem.IsMacOS(): return Report(Timeline.DuplicateSelectedTracks(), Loc.T("main.duplicated_track_s"));
- }
- return false;
+ case "edit.selectAll": return Timeline.SelectAllTracks();
+ case "edit.copy": return Report(Timeline.CopySelectedTracks(), Loc.T("main.copied_track_s"));
+ case "edit.cut": return Report(Timeline.CutSelectedTracks(), Loc.T("main.cut_track_s"));
+ case "edit.paste": return Report(Timeline.PasteTracks(), Loc.T("main.pasted_track_s"));
+ // macOS: the Edit menu's Duplicate accelerator gets there first (OnMenuDuplicate).
+ case "edit.duplicate" when !OperatingSystem.IsMacOS(): return Report(Timeline.DuplicateSelectedTracks(), Loc.T("main.duplicated_track_s"));
+ case "edit.delete": return Report(Timeline.DeleteSelectedTracks(), Loc.T("main.deleted_track_s"));
}
- if (e.KeyModifiers == KeyModifiers.None && (e.Key == Key.Delete || e.Key == Key.Back))
- return Report(Timeline.DeleteSelectedTracks(), Loc.T("main.deleted_track_s"));
return false;
bool Report(bool done, string status)
@@ -433,8 +432,8 @@ public partial class MainWindow
internal void HandleKeyUp(KeyEventArgs e)
{
- // Clear the held-key latch for every key (piano notes + toggles like R/M/Z/X/C/V that
- // de-dupe auto-repeat), and release the note at the exact pitch it started on.
+ // Clear the held-key latch for every key (piano notes + toggles like record, metronome
+ // and the octave / velocity keys that de-dupe auto-repeat), and release the note at the exact pitch it started on.
_heldKeys.Remove(e.Key);
if (_vm is not null && _heldNotePitch.Remove(e.Key, out int pitch))
{
@@ -444,7 +443,7 @@ public partial class MainWindow
else base.OnKeyUp(e);
}
- // Z/X: shift the computer-keyboard octave (typing keyboard). Clamped so the whole
+ // Shift the computer-keyboard octave (typing keyboard). Clamped so the whole
// A–K range stays within MIDI 0..127. Shows the resulting octave of the base 'A' (C) key.
private void ShiftTypingOctave(int delta)
{
@@ -454,7 +453,7 @@ public partial class MainWindow
_vm.StatusText = Loc.F("main.input.keyboard_octave_c", 4 + _typingOctave);
}
- // C/V: nudge the velocity typed notes play at (1..127, typing keyboard).
+ // Nudge the velocity typed notes play at (1..127, typing keyboard).
private void ShiftTypingVelocity(int delta)
{
int prev = _typingVelocity;
diff --git a/src/managed/Nota.App/MainWindow.MenuButton.cs b/src/managed/Nota.App/MainWindow.MenuButton.cs
index d3c4d86a..98fed16b 100644
--- a/src/managed/Nota.App/MainWindow.MenuButton.cs
+++ b/src/managed/Nota.App/MainWindow.MenuButton.cs
@@ -153,7 +153,7 @@ public partial class MainWindow
private void OnMenuKeyKeyDown(object? sender, KeyEventArgs e)
{
- if (_menuBarShown || _menuKeyMenu is null) return;
+ if (_menuBarShown || _menuKeyMenu is null || Nota.App.Input.Keys.Capturing) return;
// The command palette has the keyboard while it is open (as for the transport keys).
if (PaletteOpen) { _altTapArmed = false; return; }
if (e.Key is Key.LeftAlt or Key.RightAlt)
@@ -165,7 +165,8 @@ public partial class MainWindow
return;
}
_altTapArmed = false;
- if (e.Key == Key.F10 && e.KeyModifiers == KeyModifiers.None && !_menuKeyMenu.IsOpen)
+ // Open the menu (F10 by default — a binding since specs/096; the Alt tap stays fixed).
+ if (Nota.App.Input.Keys.Is(e, "view.openMenu") && !_menuKeyMenu.IsOpen)
{
OpenMenuKeyMenu(fromKeyboard: true);
e.Handled = true;
diff --git a/src/managed/Nota.App/MainWindow.MenuKeys.cs b/src/managed/Nota.App/MainWindow.MenuKeys.cs
index 735affbc..6b3fe3bd 100644
--- a/src/managed/Nota.App/MainWindow.MenuKeys.cs
+++ b/src/managed/Nota.App/MainWindow.MenuKeys.cs
@@ -2,8 +2,8 @@
// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
//
// The menu runs registered commands (CP-24): each NativeMenuItem in MainWindow.axaml names a
-// command id (app:Commands.Id); here it gets the command's shortcut from the catalog and its
-// click runs the command. On macOS AppKit fires the shortcuts as menu key equivalents. On
+// command id (app:Commands.Id); here it gets the command's key from the user's bindings
+// (specs/096 — re-applied whenever a key changes) and its click runs the command. On macOS AppKit fires the shortcuts as menu key equivalents. On
// Windows / Linux the in-window menu bar (NativeMenuBar) only draws a gesture — it doesn't
// bind it — so HandleKeyDown dispatches them itself once the focused view has passed on the
// key, with ⌘ read as Ctrl.
@@ -14,6 +14,8 @@ using System.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using Nota.Application.Palette;
+using Nota.Application.Input;
+using Nota.App.Input;
using Nota.Application.Localization;
namespace Nota.App;
@@ -26,10 +28,15 @@ public partial class MainWindow
private void InitMenuShortcuts()
{
BindCommands();
- ToolTip.SetTip(AutomationToggle, MenuKit.Keys(Loc.T("main.menu_keys.show_parameter_automation_lanes_a")));
- // The XAML tips name the macOS keys; spell them Ctrl+… on Windows / Linux (#10).
- foreach (var c in new Control[] { RecordBtn, LoopRecordCell, MetronomeBtn, DetailMaximizeBtn })
- if (ToolTip.GetTip(c) is string tip) ToolTip.SetTip(c, MenuKit.Keys(tip));
+ // Tooltips that name a key follow its binding (specs/096) and are spelled Ctrl+… on
+ // Windows / Linux (#10).
+ Keys.SetTip(AutomationToggle, Loc.T("main.menu_keys.show_parameter_automation_lanes_a"), "view.automation");
+ foreach (var (c, id) in new (Control, string)[]
+ {
+ (RecordBtn, "transport.record"), (LoopRecordCell, "transport.loopRecordMode"), (MetronomeBtn, "transport.metronome"),
+ (LoopCell, "transport.loop"),
+ })
+ if (ToolTip.GetTip(c) is string tip) Keys.SetTip(c, tip, id);
if (NativeMenu.GetMenu(this) is not { } menu) return;
// macOS quits from the app menu (Quit Nota, ⌘Q); File → Exit is for Windows / Linux (#316).
// Settings… lives in the app menu there too (Nota → Settings…, ⌘,), so File doesn't repeat it (#444).
@@ -40,26 +47,55 @@ public partial class MainWindow
}
if (!HasMenuKey) RemoveWithSeparatorAbove(menu, "view.menuBar"); // macOS: the menu is in the system bar (#518)
Collect(menu);
+ // A key a menu item carries reaches every scope on macOS: the conflict check reads which.
+ // macOS: Settings… lives in the app menu (App.axaml), which carries its key too.
+ Keys.Bindings.SetMenuCommands(OperatingSystem.IsMacOS() ? _menuItems.Keys.Append("prefs.open") : _menuItems.Keys);
+ ApplyMenuGestures();
+ Keys.Bindings.Changed += ApplyMenuGestures;
void Collect(NativeMenu m)
{
foreach (var item in m.Items.OfType<NativeMenuItem>())
{
- if (Commands.GetId(item) is { } id && _commands.Get(id) is { } cmd)
+ if (Commands.GetId(item) is { } id && _commands.Get(id) is not null)
{
_menuItems[id] = item;
item.Click += (_, _) => _commands.Run(id);
- if (Commands.CanMenuGesture(cmd.Gesture) && Commands.Parse(cmd.Gesture) is { } g)
- {
- item.Gesture = g;
- if (!OperatingSystem.IsMacOS()) _menuShortcuts.Add(item);
- }
}
if (item.Menu is { } sub) Collect(sub);
}
}
}
+ private bool _menuGesturesSuspended;
+
+ /// <summary>Takes the keys off the menu while the Shortcuts editor records one (macOS fires
+ /// menu key equivalents before any window sees the key), and puts them back.</summary>
+ internal void SuspendMenuGestures(bool suspend)
+ {
+ _menuGesturesSuspended = suspend;
+ ApplyMenuGestures();
+ }
+
+ // Each menu item shows (and on macOS fires) its command's current key: a chord or a bare
+ // function key — a bare letter or digit as a key equivalent would swallow typing.
+ private void ApplyMenuGestures()
+ {
+ _menuShortcuts.Clear();
+ foreach (var (id, item) in _menuItems)
+ {
+ var a = Keys.Bindings.Get(id);
+ var key = a is null || a.NoMenuKey || _menuGesturesSuspended ? null : Keys.Bindings.Shown(id);
+ item.Gesture = key is { CanMenuGesture: true } k ? k.ToGesture() : null;
+ if (item.Gesture is not null && !OperatingSystem.IsMacOS()) _menuShortcuts.Add(item);
+ }
+ // The macOS app menu's Settings… (App.axaml) follows Settings' binding too.
+ if (OperatingSystem.IsMacOS() && Avalonia.Application.Current is { } app && NativeMenu.GetMenu(app) is { } appMenu)
+ foreach (var item in appMenu.Items.OfType<NativeMenuItem>())
+ if (item.Header == Loc.T("app.settings"))
+ item.Gesture = !_menuGesturesSuspended && Keys.Bindings.Shown("prefs.open") is { CanMenuGesture: true } k ? k.ToGesture() : null;
+ }
+
// Drops the item bound to commandId (searching submenus) and the separator just above it.
private static bool RemoveWithSeparatorAbove(NativeMenu m, string commandId)
{
diff --git a/src/managed/Nota.App/MainWindow.Palette.cs b/src/managed/Nota.App/MainWindow.Palette.cs
index 8860848e..7b61e6ea 100644
--- a/src/managed/Nota.App/MainWindow.Palette.cs
+++ b/src/managed/Nota.App/MainWindow.Palette.cs
@@ -41,6 +41,8 @@ public partial class MainWindow
_paletteSearch = new PaletteSearch(_paletteIndex, _paletteUsage);
_paletteIndex.Set("modular", new ModularPaletteProvider().Build());
_paletteIndex.Set("actions", new ActionPaletteProvider(_commands).Build());
+ // A rebound key shows in the palette's hints at once (specs/096).
+ Nota.App.Input.Keys.Bindings.Changed += () => _paletteIndex.Set("actions", new ActionPaletteProvider(_commands).Build());
RefreshPaletteTracks();
RefreshPaletteDevices();
_vm.Browser.DevicesRebuilt += RefreshPaletteDevices;
diff --git a/src/managed/Nota.App/MenuKit.cs b/src/managed/Nota.App/MenuKit.cs
index c70165ff..02b1aeae 100644
--- a/src/managed/Nota.App/MenuKit.cs
+++ b/src/managed/Nota.App/MenuKit.cs
@@ -38,24 +38,33 @@ internal static partial class MenuKit
public static KeyGesture Cmd(Key key, bool shift = false)
=> new(key, Primary | (shift ? KeyModifiers.Shift : KeyModifiers.None));
- public static readonly KeyGesture CopyKey = Cmd(Key.C);
- public static readonly KeyGesture CutKey = Cmd(Key.X);
- public static readonly KeyGesture PasteKey = Cmd(Key.V);
- public static readonly KeyGesture DuplicateKey = Cmd(Key.D);
- public static readonly KeyGesture PasteBouncedKey = Cmd(Key.V, shift: true);
+ // The keys context menus show, read from the user's bindings (specs/096) each time a menu
+ // is built, so a rebound key shows its new chord; null (no key shown) when unassigned.
+ public static KeyGesture? CopyKey => Bound("edit.copy");
+ public static KeyGesture? CutKey => Bound("edit.cut");
+ public static KeyGesture? PasteKey => Bound("edit.paste");
+ public static KeyGesture? DuplicateKey => Bound("edit.duplicate");
+ public static KeyGesture? PasteBouncedKey => Bound("edit.pasteBounced");
// Arrangement: Copy to Session · Session: Copy to Arrangement.
- public static readonly KeyGesture CopyToOtherViewKey = Cmd(Key.C, shift: true);
- public static readonly KeyGesture SplitKey = Cmd(Key.E);
- public static readonly KeyGesture ConsolidateKey = Cmd(Key.J);
+ public static KeyGesture? CopyToOtherViewKey => Bound("edit.copyToOtherView");
+ public static KeyGesture? SplitKey => Bound("edit.split");
+ public static KeyGesture? ConsolidateKey => Bound("edit.consolidate");
// Arrangement time selection: Duplicate Time · Insert Silence.
- public static readonly KeyGesture DuplicateTimeKey = Cmd(Key.D, shift: true);
- public static readonly KeyGesture InsertSilenceKey = Cmd(Key.I, shift: true);
- public static readonly KeyGesture LoopKey = Cmd(Key.L);
- public static readonly KeyGesture GroupKey = Cmd(Key.G);
- public static readonly KeyGesture UngroupKey = Cmd(Key.G, shift: true);
- public static readonly KeyGesture ActivateKey = new(Key.D0);
- // Delete and Backspace both delete; show the key the platform calls "delete".
- public static readonly KeyGesture DeleteKey = new(OperatingSystem.IsMacOS() ? Key.Back : Key.Delete);
+ public static KeyGesture? DuplicateTimeKey => Bound("edit.duplicateTime");
+ public static KeyGesture? InsertSilenceKey => Bound("edit.insertSilence");
+ public static KeyGesture? LoopKey => Bound("transport.loop");
+ public static KeyGesture? GroupKey => Bound("track.group");
+ public static KeyGesture? UngroupKey => Bound("track.ungroup");
+ public static KeyGesture? ActivateKey => Bound("edit.toggleClipActive");
+ // Delete and Backspace both delete; show the key the platform calls "delete" (the
+ // alternative, ⌦, off macOS) when it is bound.
+ public static KeyGesture? DeleteKey =>
+ !OperatingSystem.IsMacOS() && Input.Keys.Bindings.Current("edit.delete", Nota.Application.Input.KeySlot.Alternative) is { } del
+ ? Input.ShortcutAvaloniaExtensions.ToGesture(del) : Bound("edit.delete");
+
+ /// <summary>The gesture of an action's current key, or null.</summary>
+ public static KeyGesture? Bound(string id) =>
+ Input.Keys.Bindings.Shown(id) is { } k ? Input.ShortcutAvaloniaExtensions.ToGesture(k) : null;
/// <summary>Shortcut text written with the macOS glyphs ("⌘⇧Z", "⇧-click", "hold ⌘") as this
/// platform spells it: unchanged on macOS, "Ctrl+Shift+Z" / "Shift-click" / "hold Ctrl"
diff --git a/src/managed/Nota.App/ModularView.cs b/src/managed/Nota.App/ModularView.cs
index d8bb9472..e7d53a8e 100644
--- a/src/managed/Nota.App/ModularView.cs
+++ b/src/managed/Nota.App/ModularView.cs
@@ -20,6 +20,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
+using Nota.App.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Nota.Application;
@@ -2150,25 +2151,27 @@ public sealed partial class ModularView : UserControl
private void OnKeyDown(object? sender, KeyEventArgs e)
{
- bool mod = (e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control)) != 0;
+ if (Keys.Capturing) return;
var sel = Selected();
- if (e.Key == Key.Space) { _spaceDown = true; _viewport.Cursor = new Cursor(StandardCursorType.SizeAll); }
- else if (e.Key == Key.F && !mod) { FitNow(); e.Handled = true; }
- else if (mod && e.Key == Key.D && sel is { IsChainDevice: true }) { DuplicateNode(sel); e.Handled = true; }
- else if (!mod && e.Key == Key.B && sel is { IsChainDevice: true } or { Slot: Slot.Instrument }) { ToggleBypass(sel); e.Handled = true; }
- else if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && _selectedEdge is { IsCv: true, LinkOwner: >= 0 } ce)
+ bool delete = Keys.Owns(e, "edit.delete");
+ // Space held pans the canvas — a fixed key, like a mouse gesture (specs/096 FR-011).
+ if (e.Key == Key.Space && e.KeyModifiers == KeyModifiers.None) { _spaceDown = true; _viewport.Cursor = new Cursor(StandardCursorType.SizeAll); }
+ else if (Keys.Owns(e, "modular.fit")) { FitNow(); e.Handled = true; }
+ else if (Keys.Owns(e, "edit.duplicate") && sel is { IsChainDevice: true }) { DuplicateNode(sel); e.Handled = true; }
+ else if (Keys.Owns(e, "modular.bypass") && sel is { IsChainDevice: true } or { Slot: Slot.Instrument }) { ToggleBypass(sel); e.Handled = true; }
+ else if (delete && _selectedEdge is { IsCv: true, LinkOwner: >= 0 } ce)
{
_engine.CvLinkRemove(ce.LinkOwner, ce.LinkIndex); _selectedEdge = null;
Rebuild(); Changed?.Invoke(); e.Handled = true;
}
- else if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && _selectedEdge is { IsCv: true, ModInputField: >= 0 } me)
+ else if (delete && _selectedEdge is { IsCv: true, ModInputField: >= 0 } me)
{
RemoveModInputEdge(me); e.Handled = true;
}
- else if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && sel is { IsChainDevice: true }) { DeleteNode(sel); e.Handled = true; }
- else if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && sel is { Slot: Slot.Modulator }) { RemoveModulatorNode(sel); e.Handled = true; }
- else if (!mod && (e.Key == Key.Delete || e.Key == Key.Back) && sel is not null && FixedReason(sel) is { } why) { _status.Text = why; e.Handled = true; }
- else if (e.Key == Key.Escape && _expanded.Count > 0) { _expanded.Clear(); Rebuild(); e.Handled = true; }
+ else if (delete && sel is { IsChainDevice: true }) { DeleteNode(sel); e.Handled = true; }
+ else if (delete && sel is { Slot: Slot.Modulator }) { RemoveModulatorNode(sel); e.Handled = true; }
+ else if (delete && sel is not null && FixedReason(sel) is { } why) { _status.Text = why; e.Handled = true; }
+ else if (Keys.Owns(e, "edit.cancel") && _expanded.Count > 0) { _expanded.Clear(); Rebuild(); e.Handled = true; }
}
private void OnKeyUp(object? sender, KeyEventArgs e)
diff --git a/src/managed/Nota.App/PianoRollView.Controllers.cs b/src/managed/Nota.App/PianoRollView.Controllers.cs
index 0a86306f..760383da 100644
--- a/src/managed/Nota.App/PianoRollView.Controllers.cs
+++ b/src/managed/Nota.App/PianoRollView.Controllers.cs
@@ -20,6 +20,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
+using Nota.App.Input;
using Avalonia.Media;
using Nota.Application;
using Nota.Application.Editing;
@@ -687,8 +688,8 @@ public sealed partial class PianoRollView
protected override void OnKeyDown(KeyEventArgs e)
{
- if (IsSwitch && _selBlock >= 0 && (e.Key == Key.Delete || e.Key == Key.Back)) { DeleteBlock(_selBlock); e.Handled = true; return; }
- if (e.Key == Key.Escape && _selBlock >= 0) { _selBlock = -1; InvalidateVisual(); e.Handled = true; return; }
+ if (IsSwitch && _selBlock >= 0 && Keys.Owns(e, "edit.delete")) { DeleteBlock(_selBlock); e.Handled = true; return; }
+ if (Keys.Owns(e, "edit.cancel") && _selBlock >= 0) { _selBlock = -1; InvalidateVisual(); e.Handled = true; return; }
base.OnKeyDown(e);
}
diff --git a/src/managed/Nota.App/PianoRollView.cs b/src/managed/Nota.App/PianoRollView.cs
index 55e93465..9f0e727f 100644
--- a/src/managed/Nota.App/PianoRollView.cs
+++ b/src/managed/Nota.App/PianoRollView.cs
@@ -23,6 +23,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
+using Nota.App.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Threading;
@@ -2835,60 +2836,72 @@ public sealed partial class PianoRollView : UserControl
protected override void OnKeyDown(KeyEventArgs e)
{
- bool meta = (e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control)) != 0;
- bool shift = (e.KeyModifiers & KeyModifiers.Shift) != 0;
- if (!meta && (e.Key == Key.Delete || e.Key == Key.Back)) { if (_o.DeleteSelection()) e.Handled = true; return; }
- // ⇧F: Fit to notes. Handled here, the window's computer-keyboard note map never
- // sees it, so no F sounds.
- if (e.Key == Key.F && e.KeyModifiers == KeyModifiers.Shift) { _o.FitToNotes(); e.Handled = true; return; }
- if (e.Key == Key.F && e.KeyModifiers == (KeyModifiers.Shift | KeyModifiers.Alt)) { _o.SetFold(!_o.Folded, user: true); e.Handled = true; return; } // Fold (specs/045)
- if (!meta && e.Key == Key.Escape && _o._selection.Count > 0)
+ if (Keys.Capturing) return;
+ // Every key is a binding (specs/096): the piano roll's own (roll.*) and the shared
+ // editing actions (edit.*), which mean "the notes" while this grid has focus.
+ if (Keys.Owns(e, "edit.delete")) { if (_o.DeleteSelection()) e.Handled = true; return; }
+ // Fit to notes. Handled here, the window's computer-keyboard note map never sees it,
+ // so no note sounds.
+ if (Keys.Owns(e, "roll.fitNotes")) { _o.FitToNotes(); e.Handled = true; return; }
+ if (Keys.Owns(e, "roll.fold")) { _o.SetFold(!_o.Folded, user: true); e.Handled = true; return; } // Fold (specs/045)
+ if (Keys.Owns(e, "edit.cancel") && _o._selection.Count > 0)
{
_o.SettlePlacement();
_o._selection.Clear(); _o.Invalidate(); _o.Changed?.Invoke(); e.Handled = true; return;
}
- // Arrow keys nudge the selection: ←/→ by the grid in time, ↑/↓ by a semitone
- // (Shift = an octave). The move auto-scrolls to keep pitch-shifted notes in view.
- // ⇧←/⇧→ shorten/lengthen by the grid; ⌥↑/⌥↓ change velocity by 10 (⌥⇧ by 1).
- bool alt = (e.KeyModifiers & KeyModifiers.Alt) != 0;
- if (!meta && _o._selection.Count > 0)
- {
- if (alt)
+ // Nudge the selection: in time by the grid, in pitch by a semitone or an octave (the
+ // move auto-scrolls to keep pitch-shifted notes in view); shorten / lengthen by the
+ // grid; velocity by 10 or by 1.
+ // Asked first, so a move key with nothing selected is still the piano roll's and
+ // never reaches the whole-clip command on the same key (roll.octaveUp).
+ if (Keys.OwnedBy(e, NoteMoves) is { } move)
+ {
+ if (_o._selection.Count == 0) return;
+ bool done = move switch
{
- switch (e.Key)
- {
- case Key.Up: if (_o.NudgeVelocity(shift ? 1 : 10)) e.Handled = true; return;
- case Key.Down: if (_o.NudgeVelocity(shift ? -1 : -10)) e.Handled = true; return;
- }
- }
- else switch (e.Key)
- {
- case Key.Left when shift: if (_o.ResizeSelection(-1)) e.Handled = true; return;
- case Key.Right when shift: if (_o.ResizeSelection(+1)) e.Handled = true; return;
- case Key.Left: if (_o.MoveSelection(0, -_o.SnapStep)) e.Handled = true; return;
- case Key.Right: if (_o.MoveSelection(0, +_o.SnapStep)) e.Handled = true; return;
- case Key.Up: if (_o.MoveSelection(shift ? 12 : 1, 0)) e.Handled = true; return;
- case Key.Down: if (_o.MoveSelection(shift ? -12 : -1, 0)) e.Handled = true; return;
- }
+ "roll.moveLeft" => _o.MoveSelection(0, -_o.SnapStep),
+ "roll.moveRight" => _o.MoveSelection(0, +_o.SnapStep),
+ "roll.transposeUp" => _o.MoveSelection(1, 0),
+ "roll.transposeDown" => _o.MoveSelection(-1, 0),
+ "roll.octaveUp" => _o.MoveSelection(12, 0),
+ "roll.octaveDown" => _o.MoveSelection(-12, 0),
+ "roll.shorten" => _o.ResizeSelection(-1),
+ "roll.lengthen" => _o.ResizeSelection(+1),
+ "roll.velocityUp" => _o.NudgeVelocity(10),
+ "roll.velocityDown" => _o.NudgeVelocity(-10),
+ "roll.velocityUpFine" => _o.NudgeVelocity(1),
+ _ => _o.NudgeVelocity(-1),
+ };
+ if (done) e.Handled = true;
+ return;
}
- if (meta && e.Key == Key.A)
+ if (Keys.Owns(e, "edit.selectAll"))
{
_o.SettlePlacement();
_o._selection.Clear();
for (int i = 0; i < _o._notes.Count; i++) if (!_o.IsLocked(i)) _o._selection.Add(i);
_o.Invalidate(); _o.Changed?.Invoke(); e.Handled = true; return;
}
- if (meta && e.Key == Key.D) // cross-platform fallback (macOS uses the native menu)
+ if (Keys.Owns(e, "edit.duplicate")) // cross-platform fallback (macOS uses the native menu)
{
if (_o.DuplicateSelection()) e.Handled = true;
return;
}
// Clipboard (the Edit-menu items carry no gesture, so these reach us here).
- if (meta && e.Key == Key.C) { if (_o.CopySelection()) e.Handled = true; return; }
- if (meta && e.Key == Key.X) { if (_o.CutSelection()) e.Handled = true; return; }
- if (meta && e.Key == Key.V) { if (_o.PasteClipboard()) e.Handled = true; return; }
+ switch (Keys.OwnedBy(e, "edit.copy", "edit.cut", "edit.paste"))
+ {
+ case "edit.copy": if (_o.CopySelection()) e.Handled = true; return;
+ case "edit.cut": if (_o.CutSelection()) e.Handled = true; return;
+ case "edit.paste": if (_o.PasteClipboard()) e.Handled = true; return;
+ }
base.OnKeyDown(e);
}
+
+ private static readonly string[] NoteMoves =
+ {
+ "roll.moveLeft", "roll.moveRight", "roll.transposeUp", "roll.transposeDown", "roll.octaveUp", "roll.octaveDown",
+ "roll.shorten", "roll.lengthen", "roll.velocityUp", "roll.velocityDown", "roll.velocityUpFine", "roll.velocityDownFine",
+ };
}
// ---- velocity lane (interactive) -------------------------------------
diff --git a/src/managed/Nota.App/PreferencesWindow.Shortcuts.cs b/src/managed/Nota.App/PreferencesWindow.Shortcuts.cs
new file mode 100644
index 00000000..be93aafa
--- /dev/null
+++ b/src/managed/Nota.App/PreferencesWindow.Shortcuts.cs
@@ -0,0 +1,631 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Settings → Shortcuts as an editor (specs/096, #61). Every keyboard row is a binding: click
+// its key, press a new one, confirm. Before anything is saved the row names the actions that
+// already answer that key where this one is live (Replace / Cancel), refuses keys the system
+// keeps, and notes reuses elsewhere that don't clash. Edited rows carry an accent dot, their
+// default and a reset; the header has "Edited only" and Reset all. Mouse gestures, list and
+// typing keys stay as plain read-only rows (ShortcutLayout).
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Avalonia;
+using Avalonia.Automation;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Controls.Shapes;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Avalonia.Threading;
+using Avalonia.VisualTree;
+using Nota.App.Input;
+using Nota.Application.Input;
+using Nota.Application.Localization;
+
+namespace Nota.App;
+
+public partial class PreferencesWindow
+{
+ private enum EditKind { None, Capture, Reset }
+
+ // The one row being edited: recording a key (Capture) or confirming a reset that takes a
+ // key from another action (Reset).
+ private EditKind _edit;
+ private string? _editId;
+ private KeySlot _editSlot;
+ private Shortcut? _proposed;
+ private string? _refusal;
+ private bool _editedOnly;
+ private bool _captureHooked;
+ private readonly Dictionary<string, Decorator> _rowHosts = new(StringComparer.Ordinal);
+ private Action? _renderShortcuts;
+ private Action? _applyShortcutFilter;
+ private int _shortcutsGeneration;
+ private readonly Dictionary<string, string> _rowSignatures = new(StringComparer.Ordinal);
+
+ private sealed class GroupView(string title)
+ {
+ public string Title { get; } = title;
+ public StackPanel? Root { get; set; }
+ public TextBlock Count { get; } = new()
+ {
+ FontSize = 8.5, FontFamily = NotaFonts.ValuesFamily, Foreground = TextDisabled, VerticalAlignment = VerticalAlignment.Center,
+ };
+ public List<RowView> Rows { get; } = new();
+ }
+
+ private sealed record RowView(ShortcutRow Row, Border Wrap, string Text);
+
+ // What a row shows: its keys, its edited mark and whether it is being edited.
+ private string RowSignature(string id) =>
+ $"{Bindings.Current(id)?.ToGlyphs()}|{Bindings.Current(id, KeySlot.Alternative)?.ToGlyphs()}|{Bindings.IsEdited(id)}|{(_editId == id ? _edit : EditKind.None)}";
+
+ private static KeyBindings Bindings => Keys.Bindings;
+
+ private Control ShortcutsPane()
+ {
+ var groups = new StackPanel { Spacing = 18 };
+ var empty = Caption("");
+ var filter = new TextBox { PlaceholderText = Loc.T("preferences.filter_shortcuts"), Text = _shortcutFilter, Classes = { "search" }, FontSize = 11 };
+ var resetAll = Btn(Loc.T("keys.ui.reset_all"));
+ resetAll.Click += async (_, _) =>
+ {
+ EndEdit();
+ var ok = await new ConfirmWindow(Loc.T("keys.ui.reset_all_title"), Loc.T("keys.ui.reset_all_message"),
+ Loc.T("keys.ui.reset_all_confirm"), Loc.T("common.cancel")).ShowDialog<bool>(this);
+ if (ok) Bindings.ResetAll();
+ };
+ var editedOnly = SwitchRow(Loc.T("keys.ui.edited_only"), _editedOnly, on => { _editedOnly = on; _applyShortcutFilter?.Invoke(); });
+
+ // The list is built once per visit and then only shown or hidden: the filter and Edited
+ // only toggle rows, and a changed key rebuilds just its row. Building ~270 rows at once
+ // took a noticeable moment, so the first groups are built at once and the rest follow in
+ // the background, a few at a time.
+ var views = new List<GroupView>();
+ int generation = ++_shortcutsGeneration;
+ string[] decisionShown = [];
+
+ void Build()
+ {
+ generation = ++_shortcutsGeneration;
+ groups.Children.Clear();
+ _rowHosts.Clear();
+ _rowSignatures.Clear();
+ views.Clear();
+ resetAll.IsEnabled = Bindings.AnyEdited;
+ decisionShown = Bindings.NeedsDecision.OrderBy(x => x, StringComparer.Ordinal).ToArray();
+ var layout = new List<ShortcutGroup>();
+ if (decisionShown.Length > 0)
+ layout.Add(new ShortcutGroup(Loc.T("keys.ui.needs_decision"), decisionShown.Select(id => new ShortcutRow(id)).ToList()));
+ layout.AddRange(ShortcutLayout.Build(Bindings.Actions.ToList(), MainWindow.HasMenuKey));
+ int next = 0, built = 0;
+ while (next < layout.Count && built < 40) built += Add(layout[next++], decision: next == 1 && decisionShown.Length > 0);
+ groups.Children.Add(empty);
+ ApplyFilter();
+ int gen = generation;
+ void More()
+ {
+ if (gen != _shortcutsGeneration) return; // rebuilt meanwhile
+ for (int n = 0; n < 2 && next < layout.Count; n++) Add(layout[next++], decision: false);
+ ApplyFilter();
+ if (next < layout.Count) Dispatcher.UIThread.Post(More, DispatcherPriority.Background);
+ }
+ if (next < layout.Count) Dispatcher.UIThread.Post(More, DispatcherPriority.Background);
+ }
+
+ int Add(ShortcutGroup g, bool decision)
+ {
+ var view = new GroupView(g.Title);
+ var stack = new StackPanel();
+ foreach (var r in g.Rows)
+ {
+ Control content = r.ActionId is { } id ? ActionRowHost(id, needsDecision: decision) : FixedShortcutRow(r.Key, r.Text);
+ var wrap = new Border { Background = RowBg, BorderBrush = Hairline, BorderThickness = new Thickness(0, 1, 0, 0), Child = content };
+ stack.Children.Add(wrap);
+ view.Rows.Add(new RowView(r, wrap, r.ActionId is null
+ ? (MenuKit.Keys(r.Text) + "\n" + MenuKit.Keys(r.Key)) : ""));
+ }
+ view.Root = new StackPanel
+ {
+ Spacing = 6,
+ Children =
+ {
+ new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 8, Margin = new Thickness(0, 0, 0, 4),
+ Children =
+ {
+ new TextBlock { Text = g.Title, Classes = { "SectionLabel" }, VerticalAlignment = VerticalAlignment.Center },
+ view.Count,
+ },
+ },
+ new Border
+ {
+ BorderBrush = Divider, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Group,
+ ClipToBounds = true, Child = stack,
+ },
+ },
+ };
+ views.Add(view);
+ groups.Children.Insert(Math.Max(0, groups.Children.Count - (groups.Children.Contains(empty) ? 1 : 0)), view.Root);
+ return g.Rows.Count;
+ }
+
+ void ApplyFilter()
+ {
+ // Each word must appear in the row's action, its keys or its group's title, so
+ // "keyboard" finds the whole "Play notes (computer keyboard)" group (#40) and "cmd t"
+ // the action on ⌘T (FR-017). A filter that reads as one key finds that key.
+ var words = _shortcutFilter.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+ var chord = KeyQuery(_shortcutFilter);
+ bool any = false;
+ foreach (var g in views)
+ {
+ int shown = 0;
+ foreach (var r in g.Rows)
+ {
+ bool on;
+ if (r.Row.ActionId is { } id)
+ on = (!_editedOnly || Bindings.IsEdited(id) || id == _editId || Bindings.NeedsDecision.Contains(id))
+ && (chord is { } c ? Bindings.Matches(id, c) : words.All(w => Matches(w, g.Title) || ActionMatches(w, id)));
+ else
+ on = !_editedOnly && (chord is { } c ? r.Row.Key.Split(' ').Contains(c.ToGlyphs())
+ : words.All(w => Matches(w, g.Title) || Matches(w, r.Text)));
+ r.Wrap.IsVisible = on;
+ if (on) r.Wrap.BorderThickness = new Thickness(0, shown == 0 ? 0 : 1, 0, 0); // no rule above the first
+ if (on) shown++;
+ }
+ g.Root!.IsVisible = shown > 0;
+ g.Count.Text = shown.ToString();
+ any |= shown > 0;
+ }
+ empty.Text = _editedOnly ? Loc.T("keys.ui.nothing_edited") : Loc.T("preferences.nothing_matches");
+ empty.IsVisible = !any;
+ }
+
+ // A key changed (here or anywhere): rebuild the rows whose keys or mark changed, or the
+ // whole list when "Needs a decision" changed.
+ void Changed()
+ {
+ resetAll.IsEnabled = Bindings.AnyEdited;
+ if (!Bindings.NeedsDecision.OrderBy(x => x, StringComparer.Ordinal).SequenceEqual(decisionShown)) { Build(); return; }
+ foreach (var id in _rowHosts.Keys.ToList())
+ if (_rowSignatures.GetValueOrDefault(id) != RowSignature(id)) RefreshRow(id);
+ ApplyFilter();
+ }
+
+ _renderShortcuts = Changed;
+ _applyShortcutFilter = ApplyFilter;
+ filter.TextChanged += (_, _) => { _shortcutFilter = filter.Text ?? ""; ApplyFilter(); };
+ HookCapture();
+ Build();
+
+ var header = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto,Auto"), ColumnSpacing = 16 };
+ var search = SearchField(filter, 320);
+ header.Children.Add(search);
+ Grid.SetColumn(editedOnly, 1);
+ editedOnly.VerticalAlignment = VerticalAlignment.Center;
+ header.Children.Add(editedOnly);
+ Grid.SetColumn(resetAll, 2);
+ header.Children.Add(resetAll);
+
+ return new StackPanel
+ {
+ Spacing = 18,
+ Children = { VelocityWheelSection(), header, Caption(Loc.T("keys.ui.how_to_edit")), groups },
+ };
+ }
+
+ private void OnBindingsChanged() => _renderShortcuts?.Invoke();
+
+ /// <summary>Ends a recording or a reset prompt (the page is left or the window closes).</summary>
+ private void EndShortcutEdit() { if (_edit != EditKind.None) EndEdit(); }
+
+ // ---- filter --------------------------------------------------------------------------
+
+ private static bool Matches(string word, string text) => text.Contains(word, StringComparison.OrdinalIgnoreCase);
+
+ private static bool ActionMatches(string w, string id)
+ {
+ var a = Bindings.Get(id);
+ if (a is null) return false;
+ if (Matches(w, a.Title) || Matches(w, a.Category) || a.Aliases.Any(x => Matches(w, x))) return true;
+ foreach (var slot in new[] { KeySlot.Primary, KeySlot.Alternative })
+ if (Bindings.Current(id, slot) is { } k && KeyWords(k).Any(t => Matches(w, t))) return true;
+ return false;
+ }
+
+ // The filter as one key, when it reads as one: modifier names or glyphs, then a key —
+ // "⌘T", "⌥⇧↑", "cmd t", "Ctrl+Shift+T", "shift f". Null for anything else (plain words).
+ private static Shortcut? KeyQuery(string text)
+ {
+ text = text.Trim();
+ if (text.Length == 0) return null;
+ var mods = ShortcutModifiers.None;
+ bool mac = OperatingSystem.IsMacOS();
+ int i = 0;
+ for (; i < text.Length && text[i] is KeyGlyphs.Cmd or KeyGlyphs.Option or KeyGlyphs.Ctrl or KeyGlyphs.Shift; i++)
+ mods |= text[i] switch
+ {
+ KeyGlyphs.Cmd => ShortcutModifiers.Primary, KeyGlyphs.Option => ShortcutModifiers.Alt,
+ KeyGlyphs.Ctrl => ShortcutModifiers.Ctrl, _ => ShortcutModifiers.Shift,
+ };
+ var parts = text[i..].Split([' ', '+', '-'], StringSplitOptions.RemoveEmptyEntries);
+ if (parts.Length == 0) return null;
+ bool named = i > 0;
+ for (int p = 0; p < parts.Length - 1; p++)
+ {
+ var m = parts[p].ToLowerInvariant() switch
+ {
+ "cmd" or "command" => ShortcutModifiers.Primary,
+ "ctrl" or "control" => mac ? ShortcutModifiers.Ctrl : ShortcutModifiers.Primary,
+ "alt" or "opt" or "option" => ShortcutModifiers.Alt,
+ "shift" => ShortcutModifiers.Shift,
+ _ => (ShortcutModifiers?)null,
+ };
+ if (m is null) return null;
+ mods |= m.Value;
+ named = true;
+ }
+ if (!named) return null; // a lone word stays a word
+ string key = parts[^1].Length == 1 ? parts[^1].ToUpperInvariant() : parts[^1];
+ return KeyActionCatalog.IsKnownToken(key) ? new Shortcut(mods, key) : null;
+ }
+
+ // A key written every way someone might type it: ⌘⇧T, Ctrl+Shift+T, "cmd shift t".
+ private static IEnumerable<string> KeyWords(Shortcut k)
+ {
+ yield return k.ToGlyphs();
+ yield return k.ToPlatformString(mac: false);
+ var names = new List<string>();
+ if ((k.Modifiers & ShortcutModifiers.Ctrl) != 0) names.Add("ctrl");
+ if ((k.Modifiers & ShortcutModifiers.Alt) != 0) names.AddRange(["opt", "option", "alt"]);
+ if ((k.Modifiers & ShortcutModifiers.Primary) != 0) names.AddRange(["cmd", "command", "ctrl"]);
+ if ((k.Modifiers & ShortcutModifiers.Shift) != 0) names.Add("shift");
+ yield return string.Join(" ", names) + " " + k.Key;
+ }
+
+ // ---- rows ----------------------------------------------------------------------------
+
+ private Control ActionRowHost(string id, bool needsDecision)
+ {
+ var host = new Decorator { Child = ActionRow(id, needsDecision) };
+ if (!needsDecision) { _rowHosts[id] = host; _rowSignatures[id] = RowSignature(id); }
+ return host;
+ }
+
+ private void RefreshRow(string id)
+ {
+ if (!_rowHosts.TryGetValue(id, out var host)) return;
+ host.Child = ActionRow(id, needsDecision: false);
+ _rowSignatures[id] = RowSignature(id);
+ }
+
+ private Control ActionRow(string id, bool needsDecision)
+ {
+ var a = Bindings.Get(id)!;
+ bool editing = _edit != EditKind.None && _editId == id;
+ bool edited = Bindings.IsEdited(id);
+
+ Control keys;
+ if (editing && _edit == EditKind.Capture) keys = CaptureField();
+ else
+ {
+ var wrap = new WrapPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center };
+ wrap.Children.Add(KeySlotButton(a, KeySlot.Primary));
+ if (!a.Fixed && (Bindings.Current(id) is not null || Bindings.Current(id, KeySlot.Alternative) is not null))
+ wrap.Children.Add(KeySlotButton(a, KeySlot.Alternative));
+ keys = wrap;
+ }
+
+ var title = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 7, VerticalAlignment = VerticalAlignment.Center };
+ if (edited) title.Children.Add(new Ellipse { Width = 6, Height = 6, Fill = Brass, VerticalAlignment = VerticalAlignment.Center });
+ title.Children.Add(new TextBlock
+ {
+ Text = MenuKit.Keys(a.Title), FontSize = 11, LineHeight = 17, Foreground = TextSecondary,
+ VerticalAlignment = VerticalAlignment.Center, TextWrapping = TextWrapping.Wrap,
+ });
+
+ var right = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, VerticalAlignment = VerticalAlignment.Center };
+ if (edited && !editing)
+ {
+ right.Children.Add(new TextBlock { Text = Loc.T("keys.ui.default"), FontSize = 10, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center });
+ right.Children.Add(Caps(a.DefaultPrimary, quiet: true));
+ var reset = new Button
+ {
+ Content = new Glyph(GlyphKind.Cycle, 11) { Foreground = TextSecondary }, Padding = new Thickness(5, 3),
+ Background = Brushes.Transparent, CornerRadius = NotaRadius.Field, VerticalAlignment = VerticalAlignment.Center,
+ };
+ ToolTip.SetTip(reset, Loc.T("keys.ui.reset_to_default"));
+ AutomationProperties.SetName(reset, Loc.T("keys.ui.reset_to_default"));
+ reset.Click += (_, _) => StartReset(id);
+ right.Children.Add(reset);
+ }
+
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions($"{LabelCol + 40},*,Auto"), ColumnSpacing = 12, MinHeight = 20, Margin = new Thickness(12, 7) };
+ grid.Children.Add(keys);
+ Grid.SetColumn(title, 1);
+ grid.Children.Add(title);
+ Grid.SetColumn(right, 2);
+ grid.Children.Add(right);
+
+ var stack = new StackPanel { Spacing = 0, Children = { grid } };
+ if (needsDecision) stack.Children.Add(NeedsDecisionLine(a));
+ if (editing) stack.Children.Add(EditLine(a));
+ return stack;
+ }
+
+ // One slot's key as a key-cap button; empty: "—" for the primary, a quiet "+" to add an
+ // alternative. A fixed action (macOS ⌘Q) shows its caps without a button.
+ private Control KeySlotButton(KeyAction a, KeySlot slot)
+ {
+ var key = Bindings.Current(a.Id, slot);
+ if (a.Fixed) return Caps(key, quiet: false);
+ Control face = key is { } k ? Caps(k, quiet: false)
+ : new TextBlock
+ {
+ Text = slot == KeySlot.Primary ? "—" : "+", FontSize = 11, Foreground = TextTertiary,
+ Margin = new Thickness(4, 0), VerticalAlignment = VerticalAlignment.Center,
+ };
+ var b = new Button
+ {
+ Content = face, Padding = new Thickness(3, 1), Background = Brushes.Transparent, BorderThickness = new Thickness(0),
+ CornerRadius = NotaRadius.Field, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 4, 0),
+ Cursor = new Cursor(StandardCursorType.Hand),
+ };
+ string tip = slot == KeySlot.Primary ? Loc.T("keys.ui.click_to_change") : Loc.T("keys.ui.add_alternative");
+ ToolTip.SetTip(b, tip);
+ AutomationProperties.SetName(b, $"{a.Title}: {tip}");
+ b.Click += (_, _) => StartCapture(a.Id, slot);
+ return b;
+ }
+
+ private static Control Caps(Shortcut? key, bool quiet)
+ {
+ var wrap = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center };
+ if (key is not { } k)
+ {
+ wrap.Children.Add(new TextBlock { Text = "—", FontSize = 11, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center });
+ return wrap;
+ }
+ // The default beside an edited key is quiet text, not caps: it is not the live key.
+ if (quiet)
+ {
+ wrap.Children.Add(new TextBlock { Text = k.ToPlatformString(), FontSize = 10, FontFamily = NotaFonts.ValuesFamily, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center });
+ return wrap;
+ }
+ foreach (var cap in k.ToKeyCaps()) wrap.Children.Add(KeyCap(cap));
+ return wrap;
+ }
+
+ // The capture field: an accent outline while waiting, the proposed key once pressed.
+ private Control CaptureField()
+ {
+ Control inner = _proposed is { } p ? Caps(p, quiet: false)
+ : new TextBlock { Text = Loc.T("keys.ui.press_a_shortcut"), FontSize = 11, Foreground = TextSecondary, VerticalAlignment = VerticalAlignment.Center };
+ return new Border
+ {
+ BorderBrush = Brass, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Field, Background = AccentSubtle,
+ Padding = new Thickness(6, 2), MinHeight = 24, HorizontalAlignment = HorizontalAlignment.Left, Child = inner,
+ };
+ }
+
+ private Control NeedsDecisionLine(KeyAction a)
+ {
+ var slot = Bindings.NeedsDecisionSlot(a.Id); // the slot whose default a user key took
+ var d = a.Default(slot);
+ var taker = d is { } k ? Bindings.Actions.FirstOrDefault(x => x.Id != a.Id && Bindings.Matches(x.Id, k)) : null;
+ var text = new TextBlock
+ {
+ Text = MenuKit.Keys(Loc.F("keys.ui.default_taken", d?.ToGlyphs() ?? "", taker?.Title ?? "")),
+ FontSize = 10.5, Foreground = NotaPalette.Warning, TextWrapping = TextWrapping.Wrap, VerticalAlignment = VerticalAlignment.Center,
+ };
+ var leave = Btn(Loc.T("keys.ui.leave_unassigned"));
+ leave.Click += (_, _) => Bindings.Set(a.Id, slot, null);
+ return new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 10, Margin = new Thickness(12 + LabelCol + 52, 0, 12, 8),
+ Children = { text, leave },
+ };
+ }
+
+ // Under the row being edited: what the proposed key would do, and the buttons.
+ private Control EditLine(KeyAction a)
+ {
+ var lines = new StackPanel { Spacing = 4 };
+ var buttons = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8 };
+ var cancel = Btn(Loc.T("common.cancel"));
+ cancel.Click += (_, _) => EndEdit(a.Id);
+
+ if (_edit == EditKind.Reset)
+ {
+ var conflicts = Bindings.ResetConflicts(a.Id);
+ foreach (var c in conflicts)
+ lines.Children.Add(Line(Loc.F("keys.ui.used_by", Bindings.Current(c.Action.Id, c.Slot)?.ToGlyphs() ?? "",
+ c.Action.Title, ScopeName(c.Action.Scope)), NotaPalette.Warning));
+ var replace = Btn(Loc.T("keys.ui.replace"));
+ replace.Classes.Add("primary");
+ replace.Click += (_, _) => { var id = a.Id; EndEdit(); Bindings.Reset(id, conflicts); };
+ buttons.Children.Add(replace);
+ buttons.Children.Add(cancel);
+ }
+ else
+ {
+ if (_refusal is not null) lines.Children.Add(Line(_refusal, NotaPalette.DangerBright));
+ List<KeyUse> conflicts = [];
+ if (_proposed is { } p && _refusal is null)
+ {
+ conflicts = Bindings.FindConflicts(a.Id, _editSlot, p);
+ foreach (var c in conflicts)
+ lines.Children.Add(Line(c.Action.Id == a.Id
+ ? Loc.F("keys.ui.already_this_action", p.ToGlyphs())
+ : Loc.F("keys.ui.used_by", p.ToGlyphs(), c.Action.Title, ScopeName(c.Action.Scope)), NotaPalette.Warning));
+ if (conflicts.Count == 0)
+ foreach (var s in Bindings.FindShadows(a.Id, p).Take(3))
+ lines.Children.Add(Line(s.Action.Scope.IsWindowLayer()
+ // This action's view has the keyboard first: it wins there.
+ ? Loc.F("keys.ui.shadow", p.ToGlyphs(), s.Action.Title, ScopeName(a.Scope))
+ // The other action's view wins while it has the keyboard.
+ : Loc.F("keys.ui.shadowed", p.ToGlyphs(), s.Action.Title, ScopeName(s.Action.Scope)), TextTertiary));
+ }
+ if (_proposed is { } chosen && _refusal is null)
+ {
+ bool clash = conflicts.Count > 0;
+ bool self = conflicts.Any(c => c.Action.Id == a.Id);
+ var ok = Btn(clash ? Loc.T("keys.ui.replace") : Loc.T("keys.ui.confirm"));
+ ok.Classes.Add("primary");
+ ok.IsEnabled = !self;
+ var id = a.Id; var slot = _editSlot; var replace = conflicts;
+ ok.Click += (_, _) => { EndEdit(); Bindings.Set(id, slot, chosen, replace); };
+ buttons.Children.Add(ok);
+ }
+ buttons.Children.Add(cancel);
+ var clear = Btn(Loc.T("common.clear"));
+ clear.IsEnabled = Bindings.Current(a.Id, _editSlot) is not null;
+ clear.Click += (_, _) => { var id = a.Id; var slot = _editSlot; EndEdit(); Bindings.Set(id, slot, null); };
+ buttons.Children.Add(clear);
+ var esc = Btn(Loc.T("keys.ui.assign_esc"));
+ esc.Click += (_, _) => Propose(Shortcut.None("Esc"));
+ buttons.Children.Add(esc);
+ }
+ lines.Children.Add(buttons);
+ return new Border { Margin = new Thickness(12, 0, 12, 10), Child = lines };
+
+ static TextBlock Line(string text, IBrush brush) => new()
+ {
+ Text = MenuKit.Keys(text), FontSize = 10.5, Foreground = brush, TextWrapping = TextWrapping.Wrap,
+ };
+ }
+
+ private static string ScopeName(KeyScope s) => s switch
+ {
+ KeyScope.Global => Loc.T("keys.scope.global"),
+ KeyScope.Arrangement => Loc.T("keys.scope.arrangement"),
+ KeyScope.Notes => Loc.T("keys.scope.notes"),
+ KeyScope.Session => Loc.T("keys.scope.session"),
+ KeyScope.PianoRoll => Loc.T("keys.scope.piano_roll"),
+ KeyScope.AudioEditor => Loc.T("keys.scope.audio_editor"),
+ KeyScope.Devices => Loc.T("keys.scope.devices"),
+ KeyScope.Browser => Loc.T("keys.scope.browser"),
+ _ => Loc.T("keys.scope.modular"),
+ };
+
+ // ---- editing state -------------------------------------------------------------------
+
+ private void StartCapture(string id, KeySlot slot)
+ {
+ var previous = _editId;
+ _edit = EditKind.Capture;
+ _editId = id;
+ _editSlot = slot;
+ _proposed = null;
+ _refusal = null;
+ SetCapturing(true);
+ if (previous is not null && previous != id) RefreshRow(previous);
+ RefreshRow(id);
+ }
+
+ private void StartReset(string id)
+ {
+ if (Bindings.ResetConflicts(id).Count == 0) { EndEdit(); Bindings.Reset(id); return; }
+ var previous = _editId;
+ SetCapturing(false);
+ _edit = EditKind.Reset;
+ _editId = id;
+ _proposed = null;
+ _refusal = null;
+ if (previous is not null && previous != id) RefreshRow(previous);
+ RefreshRow(id);
+ }
+
+ private void EndEdit(string? refresh = null)
+ {
+ var id = _editId;
+ _edit = EditKind.None;
+ _editId = null;
+ _proposed = null;
+ _refusal = null;
+ SetCapturing(false);
+ if ((refresh ?? id) is { } row) RefreshRow(row);
+ }
+
+ private void Propose(Shortcut chord)
+ {
+ if (_editId is null) return;
+ _proposed = chord;
+ _refusal = Bindings.Check(_editId, chord) switch
+ {
+ KeyCheck.Reserved => Loc.F("keys.ui.reserved", chord.ToGlyphs(), ReservedKeys.Reason(chord, Bindings.Platform) ?? ""),
+ KeyCheck.Navigation => Loc.F("keys.ui.navigation", chord.ToGlyphs()),
+ KeyCheck.Fixed => Loc.T("keys.ui.fixed"),
+ _ => null,
+ };
+ RefreshRow(_editId);
+ }
+
+ // While a row records, no window runs a shortcut: MainWindow and the views check
+ // Keys.Capturing, and on macOS the menu's key equivalents come off (they fire first).
+ private void SetCapturing(bool on)
+ {
+ if (Keys.Capturing == on) return;
+ Keys.Capturing = on;
+ if ((Avalonia.Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow is MainWindow mw)
+ mw.SuspendMenuGestures(on);
+ }
+
+ private void HookCapture()
+ {
+ if (_captureHooked) return;
+ _captureHooked = true;
+ // Once per window, however often the page is rebuilt: a key changed anywhere redraws it.
+ Keys.Bindings.Changed += OnBindingsChanged;
+ Closed += (_, _) => { Keys.Bindings.Changed -= OnBindingsChanged; EndEdit(); };
+ AddHandler(KeyDownEvent, OnCaptureKey, RoutingStrategies.Tunnel, handledEventsToo: true);
+ // Leaving the window cancels the recording (the next key would go elsewhere), and so
+ // does a click anywhere but the row being edited (the filter, another page, the list).
+ Deactivated += (_, _) => { if (_edit == EditKind.Capture) EndEdit(); };
+ AddHandler(PointerPressedEvent, (_, e) =>
+ {
+ if (_edit != EditKind.Capture || _editId is null) return;
+ if (_rowHosts.TryGetValue(_editId, out var host) && e.Source is Visual v
+ && v.GetSelfAndVisualAncestors().Contains(host)) return;
+ EndEdit();
+ }, RoutingStrategies.Tunnel, handledEventsToo: true);
+ }
+
+ private void OnCaptureKey(object? sender, KeyEventArgs e)
+ {
+ if (_edit != EditKind.Capture || _editId is null) return;
+ e.Handled = true; // nothing else sees a key while one is being recorded
+ if (KeyTokens.IsModifierKey(e.Key)) return; // a bare modifier: keep waiting
+ if (e.Key == Key.Escape && e.KeyModifiers == KeyModifiers.None) { EndEdit(); return; } // Assign Esc is a button
+ if (KeyTokens.HasSystemKey(e.KeyModifiers))
+ {
+ _proposed = null;
+ _refusal = Loc.F("keys.ui.reserved", OperatingSystem.IsWindows() ? "Win" : "Super", OperatingSystem.IsWindows() ? "Windows" : "Linux");
+ RefreshRow(_editId);
+ return;
+ }
+ if (KeyTokens.Chord(e) is not { } chord)
+ {
+ _proposed = null;
+ _refusal = Loc.T("keys.ui.unsupported_key");
+ RefreshRow(_editId);
+ return;
+ }
+ // Return confirms a proposal that needs no decision, as a dialog's default button does.
+ if (_proposed is { } p && p != chord && chord == Shortcut.None("Return") && _refusal is null
+ && Bindings.FindConflicts(_editId, _editSlot, p).Count == 0)
+ {
+ var id = _editId; var slot = _editSlot;
+ EndEdit();
+ Bindings.Set(id, slot, p);
+ return;
+ }
+ Propose(chord);
+ }
+}
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index 6955e1f2..6a24b640 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -90,7 +90,7 @@ public sealed partial class PreferencesWindow : NotaWindow
new Page("Language", Loc.T("preferences.language"), Loc.T("preferences.language_subtitle"), GlyphKind.Globe),
new Page("Editing", Loc.T("preferences.editing"), Loc.T("preferences.editing_subtitle"), GlyphKind.Edit),
new Page("Library", Loc.T("preferences.library"), Loc.T("preferences.content_folders_and_version_history"), GlyphKind.Library),
- new Page("Shortcuts", Loc.T("preferences.shortcuts"), Loc.T("preferences.keyboard_reference"), GlyphKind.Shortcuts),
+ new Page("Shortcuts", Loc.T("preferences.shortcuts"), Loc.T("preferences.shortcuts_subtitle"), GlyphKind.Shortcuts),
new Page("Updates", Loc.T("preferences.updates"), Loc.T("preferences.new_versions_of_nota"), GlyphKind.Update),
}),
};
@@ -260,6 +260,7 @@ public sealed partial class PreferencesWindow : NotaWindow
private void Select(int index)
{
+ EndShortcutEdit(); // a row recording a key must not keep taking keys on another page
StopTests(); // the audio panes are rebuilt on every visit — don't leave a tone / check orphaned
// Apply() refreshes latency and the input list only while their page is the one shown.
_latencyValue = _latencyDetail = null;
@@ -1513,318 +1514,6 @@ public sealed partial class PreferencesWindow : NotaWindow
// ---- Shortcuts --------------------------------------------------------
- // NB: this list mirrors the real key handlers — keep the two in sync (see the
- // `nota-shortcuts` skill). Bindings live in MainWindow.Input.cs (transport, global
- // editing, computer-keyboard notes), PianoRollView.cs (note editing) and PreviewPlayer.cs
- // (the Files tab's sample player). Written with the macOS glyphs; MenuKit.Keys spells them
- // Ctrl / Alt / Shift on Windows and Linux. A Key made only of
- // keys (see IsKeyToken) is drawn as one key-cap per token; a gesture is plain text.
- // Windows / Linux: Alt (pressed and released alone) or F10 opens the menu — the Menu key's
- // while the menu row is hidden (#518). macOS has its menu in the system bar, so Render leaves
- // the row out there. (A plain row in the list, so the docs' shortcuts generator reads it.)
- private const string MenuKeysRow = "⌥ F10";
-
- private static readonly (string Title, (string Key, string Action)[] Rows)[] ShortcutGroups =
- {
- (Loc.T("common.file"), new[]
- {
- ("⌘N ⌘O", Loc.T("preferences.new_project_open_a_project")),
- ("⌘S ⌘⇧S", Loc.T("preferences.save_records_a_version_save")),
- ("⌥⌘S", Loc.T("preferences.save_a_version_with_a")),
- ("⌘⇧E", Loc.T("preferences.export_audio")),
- ("⌘,", Loc.T("common.settings")),
- ("⌘Q", Loc.T("preferences.quit_nota_asks_about_unsaved")),
- }),
- (Loc.T("preferences.window"), new[]
- {
- ("⌥ F10", Loc.T("preferences.open_the_menu")), // = MenuKeysRow
- ("F11", Loc.T("preferences.enter_leave_full_screen_the")),
- ("⌘⇧F", Loc.T("preferences.the_clip_editor_fills_the")),
- (Loc.T("preferences.double_click_a_panel_edge"), Loc.T("preferences.reset_the_detail_panel_the")),
- }),
- (Loc.T("preferences.command_palette"), new[]
- {
- ("⌘⇧P", Loc.T("preferences.open_close_the_command_palette")),
- ("↑ ↓ PgUp PgDn", Loc.T("preferences.move_through_the_results")),
- ("Return", Loc.T("preferences.apply_where_the_palette_was")),
- ("⌘Return", Loc.T("preferences.an_instrument_or_instrument_preset")),
- ("⌥Return", Loc.T("preferences.replace_the_selected_device_instead")),
- ("⇧Return", Loc.T("preferences.apply_and_keep_the_palette")),
- ("Tab ⇧Tab", Loc.T("preferences.filter_all_actions_tracks_devices")),
- ("> @ + # ~", Loc.T("preferences.type_first_to_filter_actions")),
- ("Esc", Loc.T("preferences.close_and_go_back_where")),
- }),
- (Loc.T("common.transport"), new[]
- {
- ("Space", Loc.T("preferences.play_stop_stop_goes_back")),
- ("⇧Space", Loc.T("preferences.play_pause_the_playhead_stays")),
- ("Return", Loc.T("preferences.stop_again_back_to_the")),
- ("⌘R", Loc.T("common.record")),
- ("⌘.", Loc.T("preferences.discard_the_take_and_record")),
- ("⌘M", Loc.T("common.metronome")),
- ("⌘L", Loc.T("preferences.loop_on_off_loop_the")),
- (Loc.T("preferences.double_click_loop_brace"), Loc.T("preferences.loop_on_off_in_the")),
- (Loc.T("preferences.drag_loop_edge_drag_loop"), Loc.T("preferences.resize_that_end_of_the")),
- (Loc.T("preferences.right_click_ruler"), Loc.T("preferences.loop_on_off_loop_the_2")),
- ("P", Loc.T("preferences.show_playhead_scroll_the_arrangement")),
- ("⌘⇧R", Loc.T("preferences.loop_recording_overdub_every_pass")),
- (Loc.T("preferences.click_the_position_read_out"), Loc.T("preferences.switch_it_between_bars_and")),
- }),
- (Loc.T("preferences.arrangement_editing"), new[]
- {
- ("⌘Z ⌘⇧Z", Loc.T("preferences.undo_redo")),
- ("⌘A", Loc.T("preferences.select_all_clips")),
- ("⌘⇧A", Loc.T("preferences.toggle_automation_mode")),
- ("⌘⇧M", Loc.T("preferences.toggle_the_mixer_view")),
- ("Tab", Loc.T("preferences.cycle_devices_pattern_clip_in")),
- ("Esc", Loc.T("preferences.cancel_the_current_gesture_clear")),
- ("⌘G ⌘⇧G", Loc.T("preferences.group_ungroup_selected_tracks_on")),
- ("⌘C ⌘X ⌘V", Loc.T("preferences.copy_cut_paste_clips_a")),
- ("⌘⇧C", Loc.T("preferences.copy_the_selected_clips_to")),
- ("⌘⇧V", Loc.T("preferences.paste_the_last_range_as")),
- ("⌘D", Loc.T("preferences.duplicate_the_selected_clip_s")),
- ("⌘⇧D", Loc.T("preferences.duplicate_time_insert_a_copy")),
- ("⌘⇧I", Loc.T("preferences.insert_silence_push_everything_from")),
- ("⌘E", Loc.T("preferences.split_at_the_playhead_at")),
- ("⌘J", Loc.T("preferences.consolidate_the_selection_into_one")),
- ("0", Loc.T("preferences.deactivate_activate_the_selected_clip")),
- ("← →", Loc.T("preferences.nudge_the_selected_clips_by_2")),
- ("⌥← ⌥→", Loc.T("preferences.nudge_the_selected_clips_by")),
- ("⌥↑ ⌥↓", Loc.T("preferences.move_the_selected_clips_to")),
- (Loc.T("preferences.drag_below_the_last_track"), Loc.T("preferences.move_the_clips_to_a")),
- ("Delete", Loc.T("preferences.delete_the_selected_clip_range")),
- }),
- (Loc.T("preferences.grid_arrangement_or_clip_editor"), new[]
- {
- ("⌘1 ⌘2", Loc.T("preferences.narrow_widen_the_grid_in")),
- ("⌘3", Loc.T("preferences.triplet_grid_on_off")),
- ("⌘4", Loc.T("preferences.snap_to_grid_on_off")),
- ("⌘5", Loc.T("preferences.switch_between_the_adaptive_auto")),
- (Loc.T("preferences.alt_while_dragging"), Loc.T("preferences.move_freely_ignoring_the_grid")),
- (Loc.T("preferences.audio_clip_editor_on_adsr"), Loc.T("preferences.cmd_1_5_act_on_the_arrangement")),
- }),
- (Loc.T("preferences.tracks_after_a_click_in"), new[]
- {
- ("⌘A", Loc.T("preferences.select_all_tracks")),
- ("⇧-click ⌘-click", Loc.T("preferences.select_a_range_of_tracks")),
- ("⌘C ⌘X ⌘V", Loc.T("preferences.copy_cut_paste_the_selected_2")),
- ("⌘D", Loc.T("preferences.duplicate_the_selected_tracks")),
- ("Delete", Loc.T("preferences.delete_the_selected_tracks_a")),
- }),
- (Loc.T("preferences.devices_after_a_click_on"), new[]
- {
- ("⇧-click ⌘-click", Loc.T("preferences.select_a_range_of_devices")),
- ("Esc", Loc.T("preferences.clear_the_device_selection_so")),
- ("Esc", Loc.T("preferences.in_the_xl_panel_return")),
- ("⌘C ⌘X ⌘V", Loc.T("preferences.copy_cut_paste_the_selected")),
- ("⌘D", Loc.T("preferences.duplicate_the_selected_devices_each")),
- ("⌘G", Loc.T("preferences.group_the_selected_devices_into")),
- ("⌘⇧G", Loc.T("preferences.take_the_devices_out_of")),
- ("Delete", Loc.T("preferences.delete_the_selected_devices_with")),
- (Loc.T("preferences.drag_a_selected_devices_header"), Loc.T("preferences.move_the_selected_devices_of")),
- (Loc.T("preferences.drag_a_device_onto_a"), Loc.T("preferences.move_it_there_out_of")),
- (Loc.T("preferences.drag_a_device_onto_a_2"), Loc.T("preferences.copy_it_there")),
- }),
- (Loc.T("preferences.browser_files_after_a_click"), new[]
- {
- ("⌘[ ⌘]", Loc.T("preferences.back_forward_in_the_browse")),
- ("⌘↑", Loc.T("preferences.up_to_the_parent_folder")),
- ("⌘L", Loc.T("preferences.type_or_paste_a_path")),
- ("Return", Loc.T("preferences.open_the_selected_folder_browse")),
- }),
- (Loc.T("preferences.racks"), new[]
- {
- ("Esc", Loc.T("preferences.end_macro_mapping_map_on")),
- (Loc.T("preferences.drag_a_zone_edge"), Loc.T("preferences.set_a_chains_key_velocity")),
- (Loc.T("preferences.hover_the_zones"), Loc.T("preferences.see_which_chains_a_note")),
- (Loc.T("preferences.double_click_a_chain_or"), Loc.T("preferences.rename_it")),
- (Loc.T("preferences.right_click_a_macro"), Loc.T("preferences.map_it_to_a_parameter")),
- (Loc.T("preferences.drag_a_devices_header"), Loc.T("preferences.move_it_within_its_chain")),
- (Loc.T("preferences.click_a_device"), Loc.T("preferences.select_it_for_c_x")),
- }),
- (Loc.T("preferences.modular_after_a_click_on"), new[]
- {
- ("F", Loc.T("preferences.fit_every_node_on_screen")),
- ("B", Loc.T("preferences.bypass_the_selected_device")),
- ("⌘D", Loc.T("preferences.duplicate_the_selected_device_with")),
- ("Delete", Loc.T("preferences.delete_the_selected_device_modulator")),
- ("Esc", Loc.T("preferences.show_fewer_parameters_on_every")),
- }),
- (Loc.T("preferences.session_after_a_click_in"), new[]
- {
- ("← → ↑ ↓", Loc.T("preferences.move_the_selection_between_slots")),
- ("Return", Loc.T("preferences.launch_the_selected_clip_or")),
- ("⌘C ⌘X ⌘V", Loc.T("preferences.copy_cut_paste_a_clip")),
- ("⌘⇧C", Loc.T("preferences.copy_the_selected_clip_group")),
- ("⌘D", Loc.T("preferences.duplicate_a_clip_into_the")),
- ("⌘I", Loc.T("preferences.insert_a_scene_below_the")),
- ("F2", Loc.T("preferences.rename_the_selected_clip_or")),
- ("Delete", Loc.T("preferences.delete_the_selected_clip_or")),
- (Loc.T("preferences.drag_clip"), Loc.T("preferences.move_it_to_another_slot")),
- (Loc.T("preferences.drag_scene"), Loc.T("preferences.reorder_scenes")),
- (Loc.T("preferences.double_click_slot"), Loc.T("preferences.edit_the_clip_an_empty")),
- (Loc.T("preferences.double_click_header"), Loc.T("preferences.rename_the_track")),
- (Loc.T("preferences.right_click_header_or_grid"), Loc.T("preferences.add_an_instrument_audio_or")),
- }),
- (Loc.T("common.piano_roll"), new[]
- {
- ("← →", Loc.T("preferences.move_notes_by_the_grid")),
- ("↑ ↓", Loc.T("preferences.transpose_by_a_semitone")),
- ("⇧↑ ⇧↓", Loc.T("preferences.transpose_by_an_octave")),
- ("⇧← ⇧→", Loc.T("preferences.shorten_lengthen_the_notes_by")),
- ("⌥↑ ⌥↓", Loc.T("preferences.velocity_10_10_by_1")),
- (Loc.T("preferences.wheel_over_a_note"), Loc.T("preferences.change_its_velocity_the_whole")),
- ("⌘A", Loc.T("preferences.select_all_notes")),
- ("⌘D", Loc.T("preferences.duplicate_the_selection_replaces_the")),
- ("⌘C ⌘X ⌘V", Loc.T("preferences.copy_cut_paste_notes_paste")),
- ("Esc", Loc.T("preferences.deselect_moved_or_pasted_notes")),
- ("Delete", Loc.T("preferences.delete_the_selected_notes")),
- (Loc.T("preferences.double_click_empty_grid"), Loc.T("preferences.add_a_note_with_the")),
- (Loc.T("preferences.double_click_and_hold_drag"), Loc.T("preferences.shape_the_new_note_move")),
- (Loc.T("preferences.drag_note_edge"), Loc.T("preferences.change_the_notes_start_or")),
- (Loc.T("preferences.click_drag_the_ruler"), Loc.T("preferences.move_the_playhead_there_drag_2")),
- (Loc.T("preferences.drag_the_playhead_line"), Loc.T("preferences.scrub_the_playhead_on_the")),
- (Loc.T("preferences.drag_velocity_stem"), Loc.T("preferences.set_velocity_selected_notes_move")),
- (Loc.T("preferences.double_click_velocity_stem"), Loc.T("preferences.put_the_note_back_to")),
- (Loc.T("preferences.right_click_velocity_stem"), Loc.T("preferences.reset_velocity_from_a_menu")),
- (Loc.T("preferences.drag_in_the_bend_pres"), Loc.T("preferences.draw_the_selected_notes_mpe")),
- (Loc.T("preferences.double_click_in_an_mpe"), Loc.T("preferences.add_a_point_on_a")),
- (Loc.T("preferences.click_the_bend_lanes_range"), Loc.T("preferences.pick_how_far_the_bend")),
- (Loc.T("preferences.click_the_controller_tab"), Loc.T("preferences.show_primary_controller_lane")),
- (Loc.T("preferences.click_lane_controller_dropdown"), Loc.T("preferences.choose_lane_controller")),
- (Loc.T("preferences.controller_lane_buttons"), Loc.T("preferences.manage_controller_lanes")),
- (Loc.T("preferences.drag_in_the_sustain_lane"), Loc.T("preferences.draw_a_pedal_block_on")),
- (Loc.T("preferences.drag_in_a_controller_lane"), Loc.T("preferences.draw_the_controllers_curve_draws")),
- (Loc.T("preferences.drag_lane_divider"), Loc.T("preferences.resize_lane_remember_height")),
- (Loc.T("preferences.click_a_clip_in_the"), Loc.T("preferences.make_it_the_active_clip")),
- (Loc.T("preferences.cmd_alt_wheel"), Loc.T("preferences.zoom_rows_vertical_zoom")),
- (Loc.T("preferences.click_a_key"), Loc.T("preferences.play_it_on_the_tracks")),
- (Loc.T("preferences.drag_on_the_keys"), Loc.T("preferences.zoom_rows_down_taller_up")),
- ("⌥ + pinch", Loc.T("preferences.zoom_rows_trackpad")),
- ("⇧F", Loc.T("preferences.fit_to_notes")),
- ("⌥⇧F", Loc.T("preferences.fold_only_the_scales_notes")),
- }),
- (Loc.T("preferences.audio_clip_editor"), new[]
- {
- (Loc.T("preferences.click_drag_the_ruler"), Loc.T("preferences.move_the_playhead_there_drag")),
- (Loc.T("preferences.drag_the_playhead_line"), Loc.T("preferences.scrub_the_playhead")),
- (Loc.T("preferences.double_click_the_wave"), Loc.T("preferences.add_a_warp_marker_on")),
- (Loc.T("preferences.drag_a_warp_marker"), Loc.T("preferences.align_the_audio_to_the")),
- ("Esc", Loc.T("preferences.while_dragging_a_warp_marker")),
- (Loc.T("preferences.drag_double_click_tempo"), Loc.T("preferences.set_the_tempo_the_clip")),
- }),
- (Loc.T("preferences.play_notes_computer_keyboard"), new[]
- {
- ("A S D F G H J K", Loc.T("preferences.white_keys_from_c4")),
- ("W E · T Y U", Loc.T("preferences.black_keys_sharps")),
- ("Z / X", Loc.T("preferences.shift_octave_down_up")),
- ("C / V", Loc.T("preferences.lower_raise_velocity")),
- }),
- (Loc.T("preferences.browser_preview"), new[]
- {
- ("↑ ↓", Loc.T("preferences.move_through_samples_presets_and")),
- (Loc.T("preferences.click_play_button"), Loc.T("preferences.play_stop_the_selected_sample")),
- (Loc.T("preferences.click_waveform"), Loc.T("preferences.play_from_that_point")),
- (Loc.T("preferences.click_wave_spec"), Loc.T("preferences.switch_the_well_between_the")),
- (Loc.T("preferences.scroll_on_the_track_button"), Loc.T("preferences.step_through_the_demo_tracks")),
- (Loc.T("preferences.alt_click_volume"), Loc.T("preferences.type_the_preview_volume_double")),
- }),
- (Loc.T("preferences.gamepad_macos"), new[]
- {
- (Loc.T("preferences.face_buttons"), Loc.T("preferences.play_c4_d4_e4_f4")),
- (Loc.T("preferences.shoulder_buttons"), Loc.T("preferences.play_g4_a4_b4_c5")),
- ("D-pad ↑ / ↓", Loc.T("preferences.shift_the_gamepad_octave")),
- ("D-pad ← / →", Loc.T("preferences.lower_raise_velocity")),
- (Loc.T("preferences.any_button"), Loc.T("preferences.mappable_through_midi_learn_a")),
- (Loc.T("preferences.sticks_triggers"), Loc.T("preferences.mappable_as_continuous_controls_a")),
- }),
- (Loc.T("preferences.mouse"), new[]
- {
- (Loc.T("preferences.double_click_clip"), Loc.T("preferences.open_in_the_clip_editor")),
- (Loc.T("preferences.double_click_a_track_header"), Loc.T("preferences.open_its_devices_in_the")),
- (Loc.T("preferences.double_click_a_browser_instrument"), Loc.T("preferences.swap_it_onto_the_selected")),
- (Loc.T("preferences.alt_double_click_a_browser"), Loc.T("preferences.always_start_a_new_track")),
- (Loc.T("preferences.right_click_the_metronome"), Loc.T("preferences.count_in_before_play_record")),
- (Loc.T("preferences.drag_an_audio_clips_adsr"), Loc.T("preferences.shape_attack_decay_sustain_release")),
- (Loc.T("preferences.click_track_header"), Loc.T("preferences.add_the_track_to_the")),
- (Loc.T("preferences.click_a_groups_link_key"), Loc.T("preferences.link_the_groups_tracks_arming")),
- (Loc.T("preferences.click_a_clip_or_arm"), Loc.T("preferences.in_a_linked_group_select")),
- (Loc.T("preferences.right_click_track_headers"), Loc.T("preferences.a_multi_selection_gets_its")),
- (Loc.T("preferences.drag_a_tracks_bottom_edge"), Loc.T("preferences.resize_the_track_header_or")),
- (Loc.T("preferences.drag_a_tracks_bottom_edge_2"), Loc.T("preferences.resize_every_track_at_once")),
- (Loc.T("preferences.double_click_a_tracks_bottom"), Loc.T("preferences.back_to_the_standard_height")),
- (Loc.T("preferences.drag_a_returns_or_the"), Loc.T("preferences.resize_that_row_header_or")),
- ("⌘-click / ⇧-click return headers", Loc.T("preferences.select_several_returns_they_resize")),
- (Loc.T("preferences.click_a_height_key_in"), Loc.T("preferences.set_every_track_to_compact")),
- (Loc.T("preferences.drag_the_track_list_edge"), Loc.T("preferences.widen_or_narrow_the_track")),
- (Loc.T("preferences.drag_sections_lane"), Loc.T("preferences.mark_a_new_section_over")),
- (Loc.T("preferences.click_section"), Loc.T("preferences.jump_the_playhead_to_its")),
- (Loc.T("preferences.double_click_section"), Loc.T("preferences.rename_it_right_click_reset")),
- (Loc.T("preferences.return_esc_renaming_a_section"), Loc.T("preferences.keep_the_name_empty_automatic")),
- (Loc.T("preferences.drag_section"), Loc.T("preferences.rearrange_the_song_it_and")),
- (Loc.T("preferences.drag_section_2"), Loc.T("preferences.move_only_the_section_marker")),
- (Loc.T("preferences.drag_section_edge"), Loc.T("preferences.resize_it_snapped_to_bars")),
- (Loc.T("preferences.right_click_section"), Loc.T("preferences.move_earlier_later_duplicate_or")),
- (Loc.T("preferences.drag_overview_strip"), Loc.T("preferences.drag_sideways_to_scroll_up")),
- (Loc.T("preferences.drag_overview_edge"), Loc.T("preferences.zoom_by_resizing_the_viewport")),
- (Loc.T("preferences.double_click_overview"), Loc.T("preferences.fit_the_whole_project_on")),
- (Loc.T("preferences.drag_a_device_header"), Loc.T("preferences.reorder_devices_or_right_click")),
- (Loc.T("preferences.right_click_a_device_header"), Loc.T("preferences.a_b_compare_move_copy")),
- (Loc.T("preferences.delete_device_selected"), Loc.T("preferences.remove_the_selected_device_the")),
- (Loc.T("preferences.drag_an_audio_clip_onto"), Loc.T("preferences.load_its_audio_into_the")),
- (Loc.T("preferences.drag_an_audio_clip_out"), Loc.T("preferences.take_it_as_a_sample")),
- (Loc.T("preferences.drag_clip_2"), Loc.T("preferences.position_freely_ignoring_the_grid")),
- (Loc.T("preferences.wheel_over_the_device_chain"), Loc.T("preferences.scroll_it_sideways_over_an")),
- (Loc.T("preferences.drag_knob"), Loc.T("preferences.change_a_device_value_hold")),
- (Loc.T("preferences.drag_slider"), Loc.T("preferences.left_right_or_up_down")),
- (Loc.T("preferences.click_a_knob_fader_or"), Loc.T("preferences.type_a_value_units_like")),
- (Loc.T("preferences.return_esc_tab_tab_typing"), Loc.T("preferences.set_it_cancel_set_it")),
- (Loc.T("preferences.click_a_graph_handle_envelope"), Loc.T("preferences.type_its_values_a_node")),
- (Loc.T("preferences.double_click_a_knob_fader"), Loc.T("preferences.reset_the_value_to_its")),
- (Loc.T("preferences.double_click_a_mod_matrix"), Loc.T("preferences.clear_the_route_volt_aurora")),
- (Loc.T("preferences.right_click_a_knob_fader"), Loc.T("preferences.type_value_reset_to_default")),
- (Loc.T("preferences.drag_jack_jack"), Loc.T("preferences.patch_a_cable_in_nota")),
- (Loc.T("preferences.click_a_rhythm_step"), Loc.T("preferences.step_on_off_accent_quiet")),
- (Loc.T("preferences.click_a_rhythm_voice"), Loc.T("preferences.select_and_play_it_drop")),
- }),
- };
-
- private Control ShortcutsPane()
- {
- var groups = new StackPanel { Spacing = 18 };
- var filter = new TextBox { PlaceholderText = Loc.T("preferences.filter_shortcuts"), Text = _shortcutFilter, Classes = { "search" }, FontSize = 11 };
-
- void Render()
- {
- groups.Children.Clear();
- // Each word must appear in the row's action, its keys or its group's title, so
- // "keyboard" finds the whole "Play notes (computer keyboard)" group (#40).
- var words = _shortcutFilter.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
- foreach (var (title, rows) in ShortcutGroups)
- {
- var shown = rows.Where(r => (MainWindow.HasMenuKey || r.Key != MenuKeysRow) && words.All(w => title.Contains(w, StringComparison.OrdinalIgnoreCase)
- || MenuKit.Keys(r.Action).Contains(w, StringComparison.OrdinalIgnoreCase)
- || MenuKit.Keys(r.Key).Contains(w, StringComparison.OrdinalIgnoreCase))).ToList();
- if (shown.Count == 0) continue;
- var head = new StackPanel
- {
- Orientation = Orientation.Horizontal, Spacing = 8, Margin = new Thickness(0, 0, 0, 4),
- Children =
- {
- new TextBlock { Text = title, Classes = { "SectionLabel" }, VerticalAlignment = VerticalAlignment.Center },
- new TextBlock { Text = shown.Count.ToString(), FontSize = 8.5, FontFamily = NotaFonts.ValuesFamily, Foreground = TextDisabled, VerticalAlignment = VerticalAlignment.Center },
- },
- };
- groups.Children.Add(new StackPanel { Spacing = 6, Children = { head, Table(shown.Select(r => ShortcutRow(r.Key, r.Action)).ToList()) } });
- }
- if (groups.Children.Count == 0) groups.Children.Add(Caption(Loc.T("preferences.nothing_matches")));
- }
- filter.TextChanged += (_, _) => { _shortcutFilter = filter.Text ?? ""; Render(); };
- Render();
-
- return new StackPanel { Spacing = 18, Children = { VelocityWheelSection(), SearchField(filter, 320), groups } };
- }
-
private static readonly double[] VelocityWheelSteps = { 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2 };
// ⇧ + wheel over a piano-roll note (specs/063): its direction and step, beside the reference.
@@ -1862,7 +1551,8 @@ public sealed partial class PreferencesWindow : NotaWindow
// A token that names a key: no lower-case letters (⌘⇧Z, ←, A, 0), or a named key.
private static bool IsKeyToken(string t) => NamedKeys.Contains(t) || !t.Any(char.IsLower);
- private static Control ShortcutRow(string key, string action)
+ // A fixed row (a mouse gesture, a list or typing key): key-caps, or the gesture as text.
+ private static Control FixedShortcutRow(string key, string action)
{
var tokens = key.Split(' ', StringSplitOptions.RemoveEmptyEntries);
Control keys;
diff --git a/src/managed/Nota.App/SessionView.Inspector.cs b/src/managed/Nota.App/SessionView.Inspector.cs
index a5aa0854..657ab039 100644
--- a/src/managed/Nota.App/SessionView.Inspector.cs
+++ b/src/managed/Nota.App/SessionView.Inspector.cs
@@ -44,6 +44,8 @@ public sealed partial class SessionView
private InspectorPreview? _inspPreview;
+ private void RebuildInspectorKeys() => RebuildInspector();
+
private void RebuildInspector()
{
_inspPreview = null;
@@ -170,6 +172,9 @@ public sealed partial class SessionView
f.ShowAt(anchor);
}
+ // The key an action button names: the user's binding (specs/096), or none.
+ private static string K(string id) => Nota.App.Input.Keys.Bindings.Glyphs(id);
+
private static Control Actions(params (string Label, string Key, Action Click)[] actions)
{
var wrap = new WrapPanel { Orientation = Orientation.Horizontal };
@@ -322,11 +327,11 @@ public sealed partial class SessionView
s.Children.Add(Swatches(p.Color, idx => Set(x => { x.Color = idx; return x; })));
s.Children.Add(Actions(
- (Loc.T("common.duplicate"), Shortcut.Cmd('D'), () => DuplicateSelection()),
- (Loc.T("session.inspector.rename"), "F2", () => RenameSelection()),
- (Loc.T("session.inspector.to_arrangement"), Shortcut.CmdShift('C'), () => CopySelectionToArrangement()),
+ (Loc.T("common.duplicate"), K("edit.duplicate"), () => DuplicateSelection()),
+ (Loc.T("session.inspector.rename"), K("session.rename"), () => RenameSelection()),
+ (Loc.T("session.inspector.to_arrangement"), K("edit.copyToOtherView"), () => CopySelectionToArrangement()),
(Loc.T("common.edit"), "", () => SlotEditRequested?.Invoke(id, scene)),
- (Loc.T("common.delete"), Shortcut.None(KeyGlyphs.Backspace), () => DeleteSelection())));
+ (Loc.T("common.delete"), K("edit.delete"), () => DeleteSelection())));
}
// A drag on a number is one undo step, however many values it passes through.
@@ -402,11 +407,11 @@ public sealed partial class SessionView
s.Children.Add(Swatches(p.Color, idx => Set(x => { x.Color = idx; return x; })));
s.Children.Add(Actions(
(Loc.T("session.launch"), "", () => LaunchSceneRow(scene)),
- (Loc.T("session.inspector.insert_below"), Shortcut.Cmd('I'), () => InsertSceneAtSelection()),
- (Loc.T("common.duplicate"), Shortcut.Cmd('D'), () => DuplicateSelection()),
- (Loc.T("session.inspector.rename"), "F2", () => RenameSelection()),
- (Loc.T("session.inspector.to_arrangement"), Shortcut.CmdShift('C'), () => CopySelectionToArrangement()),
- (Loc.T("common.delete"), Shortcut.None(KeyGlyphs.Backspace), () => DeleteSelection())));
+ (Loc.T("session.inspector.insert_below"), K("session.insertScene"), () => InsertSceneAtSelection()),
+ (Loc.T("common.duplicate"), K("edit.duplicate"), () => DuplicateSelection()),
+ (Loc.T("session.inspector.rename"), K("session.rename"), () => RenameSelection()),
+ (Loc.T("session.inspector.to_arrangement"), K("edit.copyToOtherView"), () => CopySelectionToArrangement()),
+ (Loc.T("common.delete"), K("edit.delete"), () => DeleteSelection())));
}
// ---- empty slot + group slot ------------------------------------------------------------
@@ -428,7 +433,7 @@ public sealed partial class SessionView
if (c.IsInstrument) actions.Add((Loc.T("session.insert_midi_clip"), "", () => InsertMidiClip(c.TrackId, scene)));
actions.Add(rec ? (Loc.T("session.inspector.stop_recording"), "", () => { _engine.StopSessionRecordSlot(c.TrackId); Refresh(); })
: (Loc.T("session.record_here"), "", () => { _engine.RecordSessionSlot(c.TrackId, scene); Refresh(); }));
- if (CanPaste) actions.Add((Loc.T("common.paste"), Shortcut.Cmd('V'), () => PasteSelection()));
+ if (CanPaste) actions.Add((Loc.T("common.paste"), K("edit.paste"), () => PasteSelection()));
s.Children.Add(Actions(actions.ToArray()));
}
@@ -453,8 +458,8 @@ public sealed partial class SessionView
Text = Loc.T("session.inspector.launches_every_tracks_slot_in"),
FontSize = 10, LineHeight = 16, Foreground = NotaPalette.TextTertiary, TextWrapping = TextWrapping.Wrap,
});
- s.Children.Add(Actions((Loc.T("session.inspector.launch_group_slot"), Shortcut.None(KeyGlyphs.Return), () => LaunchGroup(g, scene)), (Loc.T("session.inspector.stop_group"), "", () => StopColumn(g)),
- (Loc.T("session.inspector.to_arrangement"), Shortcut.CmdShift('C'), () => CopySelectionToArrangement())));
+ s.Children.Add(Actions((Loc.T("session.inspector.launch_group_slot"), K("session.launchSelection"), () => LaunchGroup(g, scene)), (Loc.T("session.inspector.stop_group"), "", () => StopColumn(g)),
+ (Loc.T("session.inspector.to_arrangement"), K("edit.copyToOtherView"), () => CopySelectionToArrangement())));
}
/// <summary>The selected clip's notes / waveform with a live playhead.</summary>
diff --git a/src/managed/Nota.App/SessionView.cs b/src/managed/Nota.App/SessionView.cs
index 4537ad83..72251e5e 100644
--- a/src/managed/Nota.App/SessionView.cs
+++ b/src/managed/Nota.App/SessionView.cs
@@ -19,6 +19,7 @@ using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
+using Nota.App.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Nota.Application;
@@ -138,6 +139,9 @@ public sealed partial class SessionView : UserControl
{
ValueEntry.SetScope(this, true); // Tab in a value box walks the values shown here
_engine = engine;
+ // The inspector's buttons name their keys (specs/096): redraw them when a key changes.
+ AttachedToVisualTree += (_, _) => Nota.App.Input.Keys.Bindings.Changed += RebuildInspectorKeys;
+ DetachedFromVisualTree += (_, _) => Nota.App.Input.Keys.Bindings.Changed -= RebuildInspectorKeys;
Focusable = true;
FocusAdorner = null;
@@ -645,33 +649,27 @@ public sealed partial class SessionView : UserControl
private bool HandleKey(KeyEventArgs e)
{
- if (e.Source is TextBox) return false;
- bool mod = ArrangementView.IsPrimaryDown(e.KeyModifiers);
- bool other = (e.KeyModifiers & (KeyModifiers.Alt | KeyModifiers.Shift)) != 0;
- var nav = NavCols;
- switch (e.Key)
+ if (e.Source is TextBox || Keys.Capturing) return false;
+ bool plain = (e.KeyModifiers & (KeyModifiers.Meta | KeyModifiers.Control)) == 0;
+ // The arrows walk the selection — fixed list navigation (specs/096 FR-011).
+ if (plain && e.Key is Key.Up or Key.Down or Key.Left or Key.Right)
{
- case Key.Up or Key.Down or Key.Left or Key.Right when !mod:
- Move(e.Key, nav);
- return true;
- case Key.Back or Key.Delete when !mod:
- DeleteSelection();
- return true;
- case Key.F2 when !mod:
- RenameSelection();
- return true;
- case Key.C when mod && e.KeyModifiers.HasFlag(KeyModifiers.Shift) && !e.KeyModifiers.HasFlag(KeyModifiers.Alt):
- CopySelectionToArrangement();
- return true;
+ Move(e.Key, NavCols);
+ return true;
}
- if (!mod || other) return false;
- return e.Key switch
+ // The rest are bindings: the Session's own and the shared editing actions, which act on
+ // the selected clip or scene here. Launch (Return) is handled in the window's tunnel.
+ return Keys.OwnedBy(e, "edit.delete", "session.rename", "edit.copyToOtherView", "edit.copy", "edit.cut", "edit.paste",
+ "edit.duplicate", "session.insertScene") switch
{
- Key.C => CopySelection(),
- Key.X => CutSelection(),
- Key.V => PasteSelection(),
- Key.D => DuplicateSelection(),
- Key.I => InsertSceneAtSelection(),
+ "edit.delete" => DeleteSelection() || true,
+ "session.rename" => RenameSelection() || true,
+ "edit.copyToOtherView" => CopySelectionToArrangement() || true,
+ "edit.copy" => CopySelection(),
+ "edit.cut" => CutSelection(),
+ "edit.paste" => PasteSelection(),
+ "edit.duplicate" => DuplicateSelection(),
+ "session.insertScene" => InsertSceneAtSelection(),
_ => false,
};
}
diff --git a/src/managed/Nota.Application/Input/KeyAction.cs b/src/managed/Nota.Application/Input/KeyAction.cs
new file mode 100644
index 00000000..1496269a
--- /dev/null
+++ b/src/managed/Nota.Application/Input/KeyAction.cs
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// One rebindable keyboard action (specs/096): what Preferences → Shortcuts lists and what a
+// key handler asks about. Commands from CommandCatalog keep their ids; view-level actions
+// (note map, nudges, transposes…) are declared in KeyActionCatalog beside them.
+
+namespace Nota.Application.Input;
+
+public sealed class KeyAction
+{
+ /// <summary>Stable across versions — it keys the user's settings.</summary>
+ public required string Id { get; init; }
+ public required string Title { get; init; }
+ /// <summary>The palette category (File, Edit, Piano roll…), for filtering.</summary>
+ public string Category { get; init; } = "";
+ public KeyScope Scope { get; init; }
+ public Shortcut? DefaultPrimary { get; init; }
+ public Shortcut? DefaultAlternative { get; init; }
+ /// <summary>A command-palette command (it has a palette entry and may have a menu item).</summary>
+ public bool IsCommand { get; init; }
+ /// <summary>A menu item carries this action's key (set from the menu at start-up). On macOS a
+ /// menu key equivalent fires before any view sees the key, so it reaches every scope.</summary>
+ public bool IsMenuCommand { get; set; }
+ /// <summary>The menu shows no key for it (copy / cut / paste / delete — a menu key
+ /// equivalent would take them from text fields).</summary>
+ public bool NoMenuKey { get; init; }
+ /// <summary>Listed but not editable (macOS ⌘Q, which the system's Quit owns).</summary>
+ public bool Fixed { get; init; }
+ public string[] Aliases { get; init; } = [];
+
+ public Shortcut? Default(KeySlot slot) => slot == KeySlot.Primary ? DefaultPrimary : DefaultAlternative;
+
+ public override string ToString() => Id;
+}
+
+/// <summary>An action has a primary key and one optional alternative (FR-009).</summary>
+public enum KeySlot { Primary, Alternative }
diff --git a/src/managed/Nota.Application/Input/KeyActionCatalog.cs b/src/managed/Nota.Application/Input/KeyActionCatalog.cs
new file mode 100644
index 00000000..9ea15982
--- /dev/null
+++ b/src/managed/Nota.Application/Input/KeyActionCatalog.cs
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Every rebindable keyboard action (specs/096, #61) with its scope and default keys. The
+// command-palette commands come in from CommandCatalog (same id, its gesture as the default);
+// the keys views used to compare by hand — the note map, nudges, transposes, browser and
+// Modular keys — are declared here. contracts/actions.md in the spec lists them.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Nota.Application.Localization;
+using Nota.Application.Palette;
+
+namespace Nota.Application.Input;
+
+public static class KeyActionCatalog
+{
+ private const ShortcutModifiers P = ShortcutModifiers.Primary, S = ShortcutModifiers.Shift, A = ShortcutModifiers.Alt;
+
+ /// <summary>The key tokens a binding may use (research R4), besides A–Z and 0–9.</summary>
+ public static readonly IReadOnlySet<string> NamedTokens = new HashSet<string>(StringComparer.Ordinal)
+ {
+ "Space", "Return", "Tab", "Esc", "⌫", "⌦", "←", "→", "↑", "↓", "PgUp", "PgDn", "Home", "End",
+ ",", ".", "/", ";", "'", "[", "]", "\\", "-", "=", "`",
+ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12",
+ "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24",
+ };
+
+ public static bool IsKnownToken(string key) =>
+ key.Length == 1 && (key[0] is >= 'A' and <= 'Z' or >= '0' and <= '9') || NamedTokens.Contains(key);
+
+ /// <summary>Shared editing actions (FR-010): one binding each, read by every view that copies,
+ /// pastes, deletes… — tracks, devices, clips, notes, Session, Modular.</summary>
+ public static readonly IReadOnlySet<string> Shared = new HashSet<string>(StringComparer.Ordinal)
+ {
+ "edit.copy", "edit.cut", "edit.paste", "edit.duplicate", "edit.delete", "edit.selectAll", "edit.cancel",
+ };
+
+ public static List<KeyAction> Create() => Create(OperatingSystem.IsMacOS());
+
+ public static List<KeyAction> Create(bool mac)
+ {
+ var list = new List<KeyAction>();
+ foreach (var c in CommandCatalog.Create())
+ {
+ Shortcut? primary = c.Gesture.Length > 0 ? Shortcut.Parse(c.Gesture) : null;
+ Shortcut? alt = null;
+ bool noMenuKey = false;
+ switch (c.Id)
+ {
+ case "edit.copy": primary = new(P, "C"); noMenuKey = true; break;
+ case "edit.cut": primary = new(P, "X"); noMenuKey = true; break;
+ case "edit.paste": primary = new(P, "V"); noMenuKey = true; break;
+ case "edit.delete": primary = Shortcut.None("⌫"); alt = Shortcut.None("⌦"); noMenuKey = true; break;
+ case "roll.octaveUp": primary = new(S, "↑"); break;
+ case "roll.octaveDown": primary = new(S, "↓"); break;
+ }
+ list.Add(new KeyAction
+ {
+ Id = c.Id, Title = c.Title, Category = c.Category, Scope = ScopeOf(c), IsCommand = true,
+ // Until the menu says which it carries (KeyBindings.SetMenuCommands), assume every
+ // command may be in it: the conflict check errs towards a warning, never a clash.
+ IsMenuCommand = true,
+ DefaultPrimary = primary, DefaultAlternative = alt, NoMenuKey = noMenuKey, Aliases = c.Aliases,
+ Fixed = mac && c.Id == "file.exit",
+ });
+ }
+
+ string arr = Loc.T("keys.group.arrangement"), roll = Loc.T("common.piano_roll"), edit = Loc.T("common.edit"),
+ view = Loc.T("commands.view"), notes = Loc.T("keys.group.notes");
+
+ Add("edit.cancel", Loc.T("keys.edit_cancel"), edit, KeyScope.Global, Shortcut.None("Esc"), alias: "escape deselect stop gesture");
+ Add("view.cycleDetailTab", Loc.T("keys.view_cycle_detail_tab"), view, KeyScope.Global, Shortcut.None("Tab"), alias: "devices pattern clip tab detail");
+ if (!mac) Add("view.openMenu", Loc.T("keys.view_open_menu"), view, KeyScope.Global, Shortcut.None("F10"), alias: "menu bar");
+
+ Add("arr.nudgeLeft", Loc.T("keys.arr_nudge_left"), arr, KeyScope.Arrangement, Shortcut.None("←"));
+ Add("arr.nudgeRight", Loc.T("keys.arr_nudge_right"), arr, KeyScope.Arrangement, Shortcut.None("→"));
+ Add("arr.nudgeFineLeft", Loc.T("keys.arr_nudge_fine_left"), arr, KeyScope.Arrangement, new(A, "←"));
+ Add("arr.nudgeFineRight", Loc.T("keys.arr_nudge_fine_right"), arr, KeyScope.Arrangement, new(A, "→"));
+ Add("arr.moveToTrackUp", Loc.T("keys.arr_move_to_track_up"), arr, KeyScope.Arrangement, new(A, "↑"));
+ Add("arr.moveToTrackDown", Loc.T("keys.arr_move_to_track_down"), arr, KeyScope.Arrangement, new(A, "↓"));
+
+ // The typing keyboard: the A-row is the white keys from C4, the Q-row the black keys.
+ foreach (var (id, key) in NoteKeys) Add(id, NoteTitle(id), notes, KeyScope.Notes, Shortcut.None(key), alias: "computer keyboard note piano");
+ Add("notes.octaveDown", Loc.T("keys.notes_octave_down"), notes, KeyScope.Notes, Shortcut.None("Z"), alias: "computer keyboard octave");
+ Add("notes.octaveUp", Loc.T("keys.notes_octave_up"), notes, KeyScope.Notes, Shortcut.None("X"), alias: "computer keyboard octave");
+ Add("notes.velocityDown", Loc.T("keys.notes_velocity_down"), notes, KeyScope.Notes, Shortcut.None("C"), alias: "computer keyboard velocity");
+ Add("notes.velocityUp", Loc.T("keys.notes_velocity_up"), notes, KeyScope.Notes, Shortcut.None("V"), alias: "computer keyboard velocity");
+
+ string devices = Loc.T("keys.group.devices"), browser = Loc.T("keys.group.browser"), modular = Loc.T("keys.group.modular"),
+ session = Loc.T("commands.session");
+ Add("devices.group", Loc.T("keys.devices_group"), devices, KeyScope.Devices, new(P, "G"), alias: "rack");
+ Add("devices.ungroup", Loc.T("keys.devices_ungroup"), devices, KeyScope.Devices, new(P | S, "G"), alias: "rack");
+
+ Add("browser.back", Loc.T("keys.browser_back"), browser, KeyScope.Browser, new(P, "["), mac ? null : new(A, "←"));
+ Add("browser.forward", Loc.T("keys.browser_forward"), browser, KeyScope.Browser, new(P, "]"), mac ? null : new(A, "→"));
+ Add("browser.up", Loc.T("keys.browser_up"), browser, KeyScope.Browser, new(P, "↑"), mac ? null : new(A, "↑"), alias: "parent folder");
+ Add("browser.editPath", Loc.T("keys.browser_edit_path"), browser, KeyScope.Browser, new(P, "L"), alias: "path type paste folder");
+
+ Add("modular.fit", Loc.T("keys.modular_fit"), modular, KeyScope.Modular, Shortcut.None("F"), alias: "zoom all nodes");
+ Add("modular.bypass", Loc.T("keys.modular_bypass"), modular, KeyScope.Modular, Shortcut.None("B"), alias: "off disable");
+
+ Add("session.launchSelection", Loc.T("keys.session_launch_selection"), session, KeyScope.Session, Shortcut.None("Return"), alias: "play launch slot scene");
+ Add("session.rename", Loc.T("keys.session_rename"), session, KeyScope.Session, Shortcut.None("F2"));
+
+ Add("roll.moveLeft", Loc.T("keys.roll_move_left"), roll, KeyScope.PianoRoll, Shortcut.None("←"), alias: "notes grid");
+ Add("roll.moveRight", Loc.T("keys.roll_move_right"), roll, KeyScope.PianoRoll, Shortcut.None("→"), alias: "notes grid");
+ Add("roll.transposeUp", Loc.T("keys.roll_transpose_up"), roll, KeyScope.PianoRoll, Shortcut.None("↑"), alias: "semitone pitch");
+ Add("roll.transposeDown", Loc.T("keys.roll_transpose_down"), roll, KeyScope.PianoRoll, Shortcut.None("↓"), alias: "semitone pitch");
+ Add("roll.shorten", Loc.T("keys.roll_shorten"), roll, KeyScope.PianoRoll, new(S, "←"), alias: "length");
+ Add("roll.lengthen", Loc.T("keys.roll_lengthen"), roll, KeyScope.PianoRoll, new(S, "→"), alias: "length");
+ Add("roll.velocityUp", Loc.T("keys.roll_velocity_up"), roll, KeyScope.PianoRoll, new(A, "↑"));
+ Add("roll.velocityDown", Loc.T("keys.roll_velocity_down"), roll, KeyScope.PianoRoll, new(A, "↓"));
+ Add("roll.velocityUpFine", Loc.T("keys.roll_velocity_up_fine"), roll, KeyScope.PianoRoll, new(A | S, "↑"));
+ Add("roll.velocityDownFine", Loc.T("keys.roll_velocity_down_fine"), roll, KeyScope.PianoRoll, new(A | S, "↓"));
+
+ return list;
+
+ void Add(string id, string title, string category, KeyScope scope, Shortcut primary, Shortcut? alternative = null, string alias = "") =>
+ list.Add(new KeyAction
+ {
+ Id = id, Title = title, Category = category, Scope = scope,
+ DefaultPrimary = primary, DefaultAlternative = alternative,
+ Aliases = alias.Split(' ', StringSplitOptions.RemoveEmptyEntries),
+ });
+ }
+
+ /// <summary>The note-map actions and their default keys, from C4 to C5.</summary>
+ public static readonly (string Id, string Key)[] NoteKeys =
+ {
+ ("notes.c", "A"), ("notes.cs", "W"), ("notes.d", "S"), ("notes.ds", "E"), ("notes.e", "D"),
+ ("notes.f", "F"), ("notes.fs", "T"), ("notes.g", "G"), ("notes.gs", "Y"), ("notes.a", "H"),
+ ("notes.as", "U"), ("notes.b", "J"), ("notes.c2", "K"),
+ };
+
+ private static string NoteTitle(string id) => id switch
+ {
+ "notes.c" => Loc.T("keys.notes_c"),
+ "notes.cs" => Loc.T("keys.notes_cs"),
+ "notes.d" => Loc.T("keys.notes_d"),
+ "notes.ds" => Loc.T("keys.notes_ds"),
+ "notes.e" => Loc.T("keys.notes_e"),
+ "notes.f" => Loc.T("keys.notes_f"),
+ "notes.fs" => Loc.T("keys.notes_fs"),
+ "notes.g" => Loc.T("keys.notes_g"),
+ "notes.gs" => Loc.T("keys.notes_gs"),
+ "notes.a" => Loc.T("keys.notes_a"),
+ "notes.as" => Loc.T("keys.notes_as"),
+ "notes.b" => Loc.T("keys.notes_b"),
+ "notes.c2" => Loc.T("keys.notes_c2"),
+ _ => id,
+ };
+
+ // Commands keep their palette view: Arrangement-view keys are window-wide but live only
+ // while the Arrangement shows; piano-roll and Session commands belong to their grids.
+ private static KeyScope ScopeOf(PaletteCommand c)
+ {
+ if (Shared.Contains(c.Id)) return KeyScope.Global;
+ if (c.Id.StartsWith("roll.", StringComparison.Ordinal) && c.View.Length == 0) return KeyScope.PianoRoll;
+ return c.View switch
+ {
+ "Arrangement" => KeyScope.Arrangement,
+ "Session" => KeyScope.Session,
+ _ => KeyScope.Global,
+ };
+ }
+}
diff --git a/src/managed/Nota.Application/Input/KeyBindings.cs b/src/managed/Nota.Application/Input/KeyBindings.cs
new file mode 100644
index 00000000..4e6a243a
--- /dev/null
+++ b/src/managed/Nota.Application/Input/KeyBindings.cs
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The user's keys (specs/096, #61): the defaults of KeyActionCatalog with the overrides from
+// settings on top (only changed slots are stored, so new defaults still arrive with updates).
+// Key handlers ask Matches(id, chord); the Shortcuts editor asks FindConflicts / FindShadows
+// before it applies a change. The conflict rule (research R3): two actions answer one chord at
+// the same time when they share a scope, both are window-layer, or either is carried by a
+// menu item — unless both are their shipped defaults, which are curated and smoke-tested.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Nota.Application.Input;
+
+/// <summary>An action slot that would answer the same chord.</summary>
+public readonly record struct KeyUse(KeyAction Action, KeySlot Slot);
+
+/// <summary>What capture makes of a pressed chord before it is proposed.</summary>
+public enum KeyCheck { Ok, Reserved, Navigation, Fixed }
+
+public sealed class KeyBindings
+{
+ private readonly Dictionary<string, KeyAction> _byId = new(StringComparer.Ordinal);
+ private readonly List<KeyAction> _actions;
+ private readonly Settings _settings;
+ private readonly Action? _save;
+ private readonly KeyPlatform _platform;
+ private readonly Action<string>? _warn;
+ // Effective keys per action: [0] primary, [1] alternative; null = none.
+ private readonly Dictionary<string, Shortcut?[]> _current = new(StringComparer.Ordinal);
+ private bool _warned;
+ private readonly Dictionary<string, KeySlot> _needsDecision = new(StringComparer.Ordinal);
+
+ public KeyBindings(IEnumerable<KeyAction> actions, Settings settings, Action? save = null, KeyPlatform? platform = null,
+ Action<string>? warn = null)
+ {
+ _warn = warn;
+ _actions = actions.ToList();
+ foreach (var a in _actions) _byId[a.Id] = a;
+ _settings = settings;
+ _settings.KeyBindings ??= new(); // "KeyBindings": null in a hand-edited file
+ _save = save;
+ _platform = platform ?? ReservedKeys.Current;
+ Rebuild();
+ }
+
+ /// <summary>The app's bindings, once the app has created them (null in tests that don't).</summary>
+ public static KeyBindings? Instance { get; set; }
+
+ public IReadOnlyList<KeyAction> Actions => _actions;
+ public KeyAction? Get(string id) => _byId.GetValueOrDefault(id);
+ public KeyPlatform Platform => _platform;
+
+ /// <summary>Raised after every applied change (menus, tooltips and the palette re-read keys).</summary>
+ public event Action? Changed;
+
+ /// <summary>Defaults that a user key took over after an update — listed under "Needs a decision".</summary>
+ public IReadOnlyCollection<string> NeedsDecision => _needsDecision.Keys;
+
+ /// <summary>Which slot of a "Needs a decision" action lost its default.</summary>
+ public KeySlot NeedsDecisionSlot(string id) => _needsDecision.GetValueOrDefault(id);
+
+ /// <summary>Marks the actions a menu item carries (MainWindow reads them from its menu).</summary>
+ public void SetMenuCommands(IEnumerable<string> ids)
+ {
+ var set = ids.ToHashSet(StringComparer.Ordinal);
+ foreach (var a in _actions) a.IsMenuCommand = set.Contains(a.Id);
+ Rebuild();
+ }
+
+ // ---- reading -----------------------------------------------------------------------
+
+ public Shortcut? Current(string id, KeySlot slot = KeySlot.Primary) =>
+ _current.TryGetValue(id, out var k) ? k[(int)slot] : null;
+
+ /// <summary>The primary key, else the alternative — what a menu, tooltip or hint shows.</summary>
+ public Shortcut? Shown(string id) => Current(id) ?? Current(id, KeySlot.Alternative);
+
+ /// <summary>The shown key in glyph notation ("⌘T"), or "" when the action has none.</summary>
+ public string Glyphs(string id) => Shown(id)?.ToGlyphs() ?? "";
+
+ public bool Matches(string id, Shortcut chord) =>
+ _current.TryGetValue(id, out var k) && (k[0] == chord || k[1] == chord);
+
+ public bool IsEdited(string id) =>
+ _byId.TryGetValue(id, out var a) && (Override(id, KeySlot.Primary, a) != a.DefaultPrimary
+ || Override(id, KeySlot.Alternative, a) != a.DefaultAlternative);
+
+ public bool AnyEdited => _actions.Any(a => IsEdited(a.Id));
+
+ /// <summary>The action in <paramref name="scope"/> that answers the chord, if any.</summary>
+ public KeyAction? Resolve(KeyScope scope, Shortcut chord) =>
+ _actions.FirstOrDefault(a => a.Scope == scope && Matches(a.Id, chord));
+
+ // ---- checking ----------------------------------------------------------------------
+
+ /// <summary>Keys fixed for list navigation inside a scope (FR-011): a binding there would
+ /// never fire, so capture refuses them.</summary>
+ private static readonly Dictionary<KeyScope, Shortcut[]> NavigationKeys = new()
+ {
+ [KeyScope.Session] = [Shortcut.None("←"), Shortcut.None("→"), Shortcut.None("↑"), Shortcut.None("↓")],
+ [KeyScope.Browser] = [Shortcut.None("Return"), Shortcut.None("↑"), Shortcut.None("↓")],
+ [KeyScope.Modular] = [Shortcut.None("Space")],
+ };
+
+ public KeyCheck Check(string id, Shortcut chord)
+ {
+ if (_byId.TryGetValue(id, out var a) && a.Fixed) return KeyCheck.Fixed;
+ if (ReservedKeys.Reason(chord, _platform) is not null) return KeyCheck.Reserved;
+ if (a is not null && NavigationKeys.TryGetValue(a.Scope, out var nav) && nav.Contains(chord)) return KeyCheck.Navigation;
+ // The Session grid walks its selection on an arrow with any modifier but ⌘ / ⌃.
+ if (a?.Scope == KeyScope.Session && chord.Key is "←" or "→" or "↑" or "↓"
+ && (chord.Modifiers & (ShortcutModifiers.Primary | ShortcutModifiers.Ctrl)) == 0) return KeyCheck.Navigation;
+ return KeyCheck.Ok;
+ }
+
+ /// <summary>Every other action slot that would fire on <paramref name="chord"/> together with
+ /// <paramref name="id"/> (rule R3).</summary>
+ public List<KeyUse> FindConflicts(string id, KeySlot slot, Shortcut chord, bool exemptDefaults = true)
+ {
+ var result = new List<KeyUse>();
+ if (!_byId.TryGetValue(id, out var a)) return result;
+ bool aDefault = a.Default(slot) == chord;
+ foreach (var b in _actions)
+ for (int s = 0; s < 2; s++)
+ {
+ var bs = (KeySlot)s;
+ if (b.Id == id && bs == slot) continue;
+ if (Current(b.Id, bs) != chord) continue;
+ if (b.Id == id) { result.Add(new(b, bs)); continue; } // the same key in both slots
+ if (!Overlap(a, b, chord)) continue;
+ if (exemptDefaults && aDefault && b.Default(bs) == chord && Override(b.Id, bs, b) == chord) continue;
+ result.Add(new(b, bs));
+ }
+ return result;
+ }
+
+ /// <summary>Other uses of the chord that don't conflict — another layer, where the focused
+ /// view wins (FR-014). Shown as a note.</summary>
+ public List<KeyUse> FindShadows(string id, Shortcut chord)
+ {
+ var result = new List<KeyUse>();
+ if (!_byId.TryGetValue(id, out var a)) return result;
+ foreach (var b in _actions)
+ {
+ if (b.Id == id) continue;
+ for (int s = 0; s < 2; s++)
+ if (Current(b.Id, (KeySlot)s) == chord && !Overlap(a, b, chord)
+ && a.Scope.IsWindowLayer() != b.Scope.IsWindowLayer())
+ result.Add(new(b, (KeySlot)s));
+ }
+ return result;
+ }
+
+ private static bool MenuChord(KeyAction a, Shortcut chord) => a.IsMenuCommand && !a.NoMenuKey && chord.CanMenuGesture;
+
+ private static bool Overlap(KeyAction a, KeyAction b, Shortcut chord) =>
+ a.Scope == b.Scope
+ || a.Scope.IsWindowLayer() && b.Scope.IsWindowLayer()
+ || MenuChord(a, chord) || MenuChord(b, chord);
+
+ // ---- changing ----------------------------------------------------------------------
+
+ /// <summary>Sets one slot (null chord = unassigned) and, for Replace, clears every slot in
+ /// <paramref name="replace"/> — one change, saved once.</summary>
+ public void Set(string id, KeySlot slot, Shortcut? chord, IEnumerable<KeyUse>? replace = null)
+ {
+ if (!_byId.ContainsKey(id)) return;
+ foreach (var u in replace ?? []) Write(u.Action.Id, u.Slot, null);
+ Write(id, slot, chord);
+ Commit();
+ }
+
+ /// <summary>The conflicts that resetting <paramref name="id"/> to its defaults would cause.</summary>
+ public List<KeyUse> ResetConflicts(string id)
+ {
+ var result = new List<KeyUse>();
+ if (!_byId.TryGetValue(id, out var a)) return result;
+ foreach (var slot in new[] { KeySlot.Primary, KeySlot.Alternative })
+ if (a.Default(slot) is { } d && Current(id, slot) != d)
+ result.AddRange(FindConflicts(id, slot, d).Where(u => u.Action.Id != id));
+ return result;
+ }
+
+ public void Reset(string id, IEnumerable<KeyUse>? replace = null)
+ {
+ foreach (var u in replace ?? []) Write(u.Action.Id, u.Slot, null);
+ _settings.KeyBindings.Remove(id);
+ Commit();
+ }
+
+ public void ResetAll()
+ {
+ _settings.KeyBindings.Clear();
+ Commit();
+ }
+
+ // Writes an override slot; a slot equal to its default is dropped, and an entry with both
+ // slots on their defaults goes away (FR-020).
+ private void Write(string id, KeySlot slot, Shortcut? chord)
+ {
+ var a = _byId[id];
+ _settings.KeyBindings.TryGetValue(id, out var o);
+ o ??= new KeyBindingOverride();
+ string? text = chord == a.Default(slot) ? null : chord?.ToGlyphs() ?? "";
+ if (slot == KeySlot.Primary) o.Primary = text; else o.Alternative = text;
+ if (o.Primary is null && o.Alternative is null) _settings.KeyBindings.Remove(id);
+ else _settings.KeyBindings[id] = o;
+ }
+
+ private void Commit()
+ {
+ Rebuild();
+ _save?.Invoke();
+ Changed?.Invoke();
+ }
+
+ // ---- effective map -----------------------------------------------------------------
+
+ // The slot as the settings say: an override, else the default.
+ private Shortcut? Override(string id, KeySlot slot, KeyAction a)
+ {
+ if (!_settings.KeyBindings.TryGetValue(id, out var o) || o is null) return a.Default(slot);
+ string? text = slot == KeySlot.Primary ? o.Primary : o.Alternative;
+ if (text is null) return a.Default(slot);
+ if (text.Length == 0) return null;
+ return TryParse(text, out var s) ? s : a.Default(slot);
+ }
+
+ public static bool TryParse(string glyphs, out Shortcut shortcut)
+ {
+ shortcut = Shortcut.Parse(glyphs);
+ return shortcut.Key.Length > 0 && KeyActionCatalog.IsKnownToken(shortcut.Key);
+ }
+
+ private void Rebuild()
+ {
+ _current.Clear();
+ _needsDecision.Clear();
+ // Drop what can't be used: unknown ids and keys that don't parse (FR-021).
+ if (!_warned) foreach (var (id, o) in _settings.KeyBindings.ToList())
+ {
+ if (o is null) { _warn?.Invoke($"Nota shortcuts: ignoring an empty entry for '{id}'"); continue; }
+ if (!_byId.ContainsKey(id)) { _warn?.Invoke($"Nota shortcuts: ignoring unknown action '{id}'"); continue; }
+ foreach (var t in new[] { o.Primary, o.Alternative })
+ if (!string.IsNullOrEmpty(t) && !TryParse(t, out _))
+ _warn?.Invoke($"Nota shortcuts: ignoring unreadable key '{t}' for '{id}'");
+ }
+ _warned = true;
+ foreach (var a in _actions)
+ _current[a.Id] = [Override(a.Id, KeySlot.Primary, a), Override(a.Id, KeySlot.Alternative, a)];
+
+ // A default that now collides with a user's key (a new default after an update, or a
+ // hand-edited file): the user's key wins, the default rests until the user decides.
+ var userKeys = new List<(KeyAction A, KeySlot S, Shortcut K)>();
+ foreach (var a in _actions)
+ if (_settings.KeyBindings.GetValueOrDefault(a.Id) is not null)
+ for (int s = 0; s < 2; s++)
+ if (_current[a.Id][s] is { } k && k != a.Default((KeySlot)s)) userKeys.Add((a, (KeySlot)s, k));
+ if (userKeys.Count == 0) return;
+ foreach (var a in _actions)
+ for (int s = 0; s < 2; s++)
+ {
+ if (_current[a.Id][s] is not { } k) continue;
+ bool user = userKeys.Any(u => u.A == a && u.S == (KeySlot)s);
+ foreach (var u in userKeys)
+ {
+ if (u.A == a && u.S == (KeySlot)s) continue;
+ if (u.K != k || !Overlap(a, u.A, k)) continue;
+ // Two user keys on one chord: the first one listed keeps it.
+ if (user && userKeys.FindIndex(x => x.A == a && x.S == (KeySlot)s) < userKeys.IndexOf(u)) continue;
+ _current[a.Id][s] = null;
+ _needsDecision.TryAdd(a.Id, (KeySlot)s);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/managed/Nota.Application/Input/KeyScope.cs b/src/managed/Nota.Application/Input/KeyScope.cs
new file mode 100644
index 00000000..f3784b4a
--- /dev/null
+++ b/src/managed/Nota.Application/Input/KeyScope.cs
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Where a key action is live (specs/096). Window-layer scopes are handled by the main window
+// in one fixed order, so they are live together; a focus-layer scope handles its keys first
+// while it has the keyboard. The conflict rule in KeyBindings reads this split.
+
+namespace Nota.Application.Input;
+
+public enum KeyScope
+{
+ /// <summary>The main window (or the floating detail window) has the keyboard.</summary>
+ Global,
+ /// <summary>The Arrangement is shown (clip nudges, show playhead, clip on/off).</summary>
+ Arrangement,
+ /// <summary>The computer-keyboard notes — the last thing a key falls through to.</summary>
+ Notes,
+ /// <summary>The Session grid has focus.</summary>
+ Session,
+ /// <summary>The piano-roll grid or its controller lanes have focus.</summary>
+ PianoRoll,
+ /// <summary>The audio clip editor is shown.</summary>
+ AudioEditor,
+ /// <summary>The device chain or a rack card has focus.</summary>
+ Devices,
+ /// <summary>The browser's Files tab has focus.</summary>
+ Browser,
+ /// <summary>The Modular canvas has focus.</summary>
+ Modular,
+}
+
+public static class KeyScopes
+{
+ /// <summary>True for the scopes the main window runs together (Global, Arrangement, Notes).</summary>
+ public static bool IsWindowLayer(this KeyScope s) => s is KeyScope.Global or KeyScope.Arrangement or KeyScope.Notes;
+}
diff --git a/src/managed/Nota.Application/Input/ReservedKeys.cs b/src/managed/Nota.Application/Input/ReservedKeys.cs
new file mode 100644
index 00000000..a2de30c1
--- /dev/null
+++ b/src/managed/Nota.Application/Input/ReservedKeys.cs
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Key combinations the operating system keeps for itself (specs/096, FR-008): the Shortcuts
+// editor refuses them with a reason. Not exhaustive — other apps' global shortcuts can't be
+// detected, and the editor says so.
+
+using System;
+using System.Collections.Generic;
+
+namespace Nota.Application.Input;
+
+public enum KeyPlatform { Mac, Windows, Linux }
+
+public static class ReservedKeys
+{
+ public static KeyPlatform Current =>
+ OperatingSystem.IsMacOS() ? KeyPlatform.Mac : OperatingSystem.IsWindows() ? KeyPlatform.Windows : KeyPlatform.Linux;
+
+ private const ShortcutModifiers P = ShortcutModifiers.Primary, S = ShortcutModifiers.Shift,
+ A = ShortcutModifiers.Alt, C = ShortcutModifiers.Ctrl;
+
+ private static readonly HashSet<Shortcut> Mac = new()
+ {
+ new(P, "Q"), new(P, "H"), new(P | A, "H"), new(P, "Tab"), new(P | S, "Tab"), new(P, "Space"),
+ new(C, "Space"), new(P, "`"), new(P | S, "3"), new(P | S, "4"), new(P | S, "5"),
+ new(C | P, "Q"), new(P | A, "Esc"),
+ };
+
+ // ⌘ (Primary) is Ctrl on Windows / Linux, so Ctrl+Esc is written with P there.
+ private static readonly HashSet<Shortcut> Windows = new()
+ {
+ new(A, "F4"), new(A, "Tab"), new(A | S, "Tab"), new(A, "Esc"), new(A, "Space"), new(P, "Esc"),
+ new(P | S, "Esc"), new(P | A, "⌦"),
+ };
+
+ private static readonly HashSet<Shortcut> Linux = new()
+ {
+ new(A, "F4"), new(A, "Tab"), new(A | S, "Tab"), new(P | A, "⌦"),
+ };
+
+ /// <summary>Why the system keeps this combination, or null when Nota may use it.</summary>
+ public static string? Reason(Shortcut s, KeyPlatform platform)
+ {
+ var set = platform switch { KeyPlatform.Mac => Mac, KeyPlatform.Windows => Windows, _ => Linux };
+ if (set.Contains(s)) return platform switch
+ {
+ KeyPlatform.Mac => "macOS",
+ KeyPlatform.Windows => "Windows",
+ _ => "Linux",
+ };
+ // Ctrl+Alt+F1…F12 switch virtual terminals on Linux.
+ if (platform == KeyPlatform.Linux && s.Modifiers == (P | A) && s.Key.Length is 2 or 3 && s.Key[0] == 'F'
+ && int.TryParse(s.Key[1..], out int f) && f is >= 1 and <= 12) return "Linux";
+ return null;
+ }
+}
diff --git a/src/managed/Nota.Application/Input/ShortcutLayout.cs b/src/managed/Nota.Application/Input/ShortcutLayout.cs
new file mode 100644
index 00000000..4f0804cb
--- /dev/null
+++ b/src/managed/Nota.Application/Input/ShortcutLayout.cs
@@ -0,0 +1,224 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// What Preferences → Shortcuts lists, in order (specs/096): one group per category of the
+// key-action catalog — so every action appears exactly once and a new one can't be forgotten —
+// with the fixed rows beside them: mouse gestures, list-navigation and text keys, the gamepad
+// (FR-004, FR-011). Fixed keys are written with the macOS glyphs; the page spells them.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Nota.Application.Localization;
+
+namespace Nota.Application.Input;
+
+/// <summary>A row: an editable action (<see cref="ActionId"/>), or a fixed key / gesture.</summary>
+public sealed record ShortcutRow(string? ActionId, string Key = "", string Text = "")
+{
+ public bool IsFixed => ActionId is null;
+}
+
+public sealed record ShortcutGroup(string Title, IReadOnlyList<ShortcutRow> Rows);
+
+public static class ShortcutLayout
+{
+ public static List<ShortcutGroup> Build(IReadOnlyList<KeyAction> actions, bool menuKey)
+ {
+ // Category order: the menus first, then the views that handle their own keys.
+ string file = Loc.T("common.file"), edit = Loc.T("common.edit"), view = Loc.T("commands.view"),
+ transport = Loc.T("common.transport"), track = Loc.T("common.track"), arrangement = Loc.T("keys.group.arrangement"),
+ grid = Loc.T("common.grid"), session = Loc.T("commands.session"), roll = Loc.T("common.piano_roll"),
+ devices = Loc.T("keys.group.devices"), modular = Loc.T("keys.group.modular"), browser = Loc.T("keys.group.browser"),
+ notes = Loc.T("keys.group.notes"), settings = Loc.T("common.settings"), help = Loc.T("commands.help");
+ string[] order = [file, edit, view, transport, track, arrangement, grid, session, roll, devices, modular, browser, notes, settings, help];
+
+ var fixedRows = new Dictionary<string, List<ShortcutRow>>(StringComparer.Ordinal)
+ {
+ [view] =
+ [
+ F(Loc.T("preferences.double_click_a_panel_edge"), Loc.T("preferences.reset_the_detail_panel_the")),
+ ],
+ [transport] =
+ [
+ F(Loc.T("preferences.double_click_loop_brace"), Loc.T("preferences.loop_on_off_in_the")),
+ F(Loc.T("preferences.drag_loop_edge_drag_loop"), Loc.T("preferences.resize_that_end_of_the")),
+ F(Loc.T("preferences.right_click_ruler"), Loc.T("preferences.loop_on_off_loop_the_2")),
+ F(Loc.T("preferences.click_the_position_read_out"), Loc.T("preferences.switch_it_between_bars_and")),
+ ],
+ [arrangement] =
+ [
+ F(Loc.T("preferences.drag_below_the_last_track"), Loc.T("preferences.move_the_clips_to_a")),
+ F("⇧-click ⌘-click", Loc.T("preferences.select_a_range_of_tracks")),
+ ],
+ [grid] =
+ [
+ F(Loc.T("preferences.alt_while_dragging"), Loc.T("preferences.move_freely_ignoring_the_grid")),
+ F(Loc.T("preferences.audio_clip_editor_on_adsr"), Loc.T("preferences.cmd_1_5_act_on_the_arrangement")),
+ ],
+ [session] =
+ [
+ F("← → ↑ ↓", Loc.T("preferences.move_the_selection_between_slots")),
+ F(Loc.T("preferences.drag_clip"), Loc.T("preferences.move_it_to_another_slot")),
+ F(Loc.T("preferences.drag_scene"), Loc.T("preferences.reorder_scenes")),
+ F(Loc.T("preferences.double_click_slot"), Loc.T("preferences.edit_the_clip_an_empty")),
+ F(Loc.T("preferences.double_click_header"), Loc.T("preferences.rename_the_track")),
+ F(Loc.T("preferences.right_click_header_or_grid"), Loc.T("preferences.add_an_instrument_audio_or")),
+ ],
+ [roll] =
+ [
+ F(Loc.T("preferences.wheel_over_a_note"), Loc.T("preferences.change_its_velocity_the_whole")),
+ F(Loc.T("preferences.double_click_empty_grid"), Loc.T("preferences.add_a_note_with_the")),
+ F(Loc.T("preferences.double_click_and_hold_drag"), Loc.T("preferences.shape_the_new_note_move")),
+ F(Loc.T("preferences.drag_note_edge"), Loc.T("preferences.change_the_notes_start_or")),
+ F(Loc.T("preferences.click_drag_the_ruler"), Loc.T("preferences.move_the_playhead_there_drag_2")),
+ F(Loc.T("preferences.drag_the_playhead_line"), Loc.T("preferences.scrub_the_playhead_on_the")),
+ F(Loc.T("preferences.drag_velocity_stem"), Loc.T("preferences.set_velocity_selected_notes_move")),
+ F(Loc.T("preferences.double_click_velocity_stem"), Loc.T("preferences.put_the_note_back_to")),
+ F(Loc.T("preferences.right_click_velocity_stem"), Loc.T("preferences.reset_velocity_from_a_menu")),
+ F(Loc.T("preferences.drag_in_the_bend_pres"), Loc.T("preferences.draw_the_selected_notes_mpe")),
+ F(Loc.T("preferences.double_click_in_an_mpe"), Loc.T("preferences.add_a_point_on_a")),
+ F(Loc.T("preferences.click_the_bend_lanes_range"), Loc.T("preferences.pick_how_far_the_bend")),
+ F(Loc.T("preferences.click_the_controller_tab"), Loc.T("preferences.show_primary_controller_lane")),
+ F(Loc.T("preferences.click_lane_controller_dropdown"), Loc.T("preferences.choose_lane_controller")),
+ F(Loc.T("preferences.controller_lane_buttons"), Loc.T("preferences.manage_controller_lanes")),
+ F(Loc.T("preferences.drag_in_the_sustain_lane"), Loc.T("preferences.draw_a_pedal_block_on")),
+ F(Loc.T("preferences.drag_in_a_controller_lane"), Loc.T("preferences.draw_the_controllers_curve_draws")),
+ F(Loc.T("preferences.drag_lane_divider"), Loc.T("preferences.resize_lane_remember_height")),
+ F(Loc.T("preferences.click_a_clip_in_the"), Loc.T("preferences.make_it_the_active_clip")),
+ F(Loc.T("preferences.cmd_alt_wheel"), Loc.T("preferences.zoom_rows_vertical_zoom")),
+ F(Loc.T("preferences.click_a_key"), Loc.T("preferences.play_it_on_the_tracks")),
+ F(Loc.T("preferences.drag_on_the_keys"), Loc.T("preferences.zoom_rows_down_taller_up")),
+ F("⌥ + pinch", Loc.T("preferences.zoom_rows_trackpad")),
+ ],
+ [devices] =
+ [
+ F("⇧-click ⌘-click", Loc.T("preferences.select_a_range_of_devices")),
+ F(Loc.T("preferences.drag_a_selected_devices_header"), Loc.T("preferences.move_the_selected_devices_of")),
+ F(Loc.T("preferences.drag_a_device_onto_a"), Loc.T("preferences.move_it_there_out_of")),
+ F(Loc.T("preferences.drag_a_device_onto_a_2"), Loc.T("preferences.copy_it_there")),
+ ],
+ [modular] =
+ [
+ F(Loc.T("keys.fixed.space_drag"), Loc.T("keys.fixed.pan_the_canvas")),
+ ],
+ [browser] =
+ [
+ F("Return", Loc.T("preferences.open_the_selected_folder_browse")),
+ ],
+ };
+ if (menuKey) fixedRows[view].Insert(0, F("⌥", Loc.T("keys.fixed.alt_tap_opens_the_menu")));
+
+ var groups = new List<ShortcutGroup>();
+ var byCategory = actions.GroupBy(a => a.Category).ToDictionary(g => g.Key, g => g.ToList(), StringComparer.Ordinal);
+ foreach (var cat in order.Concat(byCategory.Keys.Where(k => !order.Contains(k))).Distinct())
+ {
+ var rows = new List<ShortcutRow>();
+ if (byCategory.TryGetValue(cat, out var list)) rows.AddRange(list.Select(a => new ShortcutRow(a.Id)));
+ if (fixedRows.TryGetValue(cat, out var extra)) rows.AddRange(extra);
+ if (rows.Count > 0) groups.Add(new ShortcutGroup(cat, rows));
+ }
+
+ // Fixed only: keys of lists and dialogs, and what the mouse, trackpad and gamepad do.
+ groups.Add(new(Loc.T("preferences.command_palette"),
+ [
+ F("↑ ↓ PgUp PgDn", Loc.T("preferences.move_through_the_results")),
+ F("Return", Loc.T("preferences.apply_where_the_palette_was")),
+ F("⌘Return", Loc.T("preferences.an_instrument_or_instrument_preset")),
+ F("⌥Return", Loc.T("preferences.replace_the_selected_device_instead")),
+ F("⇧Return", Loc.T("preferences.apply_and_keep_the_palette")),
+ F("Tab ⇧Tab", Loc.T("preferences.filter_all_actions_tracks_devices")),
+ F("> @ + # ~", Loc.T("preferences.type_first_to_filter_actions")),
+ F("Esc", Loc.T("preferences.close_and_go_back_where")),
+ ]));
+ groups.Add(new(Loc.T("preferences.racks"),
+ [
+ F(Loc.T("preferences.drag_a_zone_edge"), Loc.T("preferences.set_a_chains_key_velocity")),
+ F(Loc.T("preferences.hover_the_zones"), Loc.T("preferences.see_which_chains_a_note")),
+ F(Loc.T("preferences.double_click_a_chain_or"), Loc.T("preferences.rename_it")),
+ F(Loc.T("preferences.right_click_a_macro"), Loc.T("preferences.map_it_to_a_parameter")),
+ F(Loc.T("preferences.drag_a_devices_header"), Loc.T("preferences.move_it_within_its_chain")),
+ F(Loc.T("preferences.click_a_device"), Loc.T("preferences.select_it_for_c_x")),
+ ]));
+ groups.Add(new(Loc.T("preferences.audio_clip_editor"),
+ [
+ F(Loc.T("preferences.click_drag_the_ruler"), Loc.T("preferences.move_the_playhead_there_drag")),
+ F(Loc.T("preferences.drag_the_playhead_line"), Loc.T("preferences.scrub_the_playhead")),
+ F(Loc.T("preferences.double_click_the_wave"), Loc.T("preferences.add_a_warp_marker_on")),
+ F(Loc.T("preferences.drag_a_warp_marker"), Loc.T("preferences.align_the_audio_to_the")),
+ F(Loc.T("preferences.drag_double_click_tempo"), Loc.T("preferences.set_the_tempo_the_clip")),
+ ]));
+ groups.Add(new(Loc.T("preferences.browser_preview"),
+ [
+ F("↑ ↓", Loc.T("preferences.move_through_samples_presets_and")),
+ F(Loc.T("preferences.click_play_button"), Loc.T("preferences.play_stop_the_selected_sample")),
+ F(Loc.T("preferences.click_waveform"), Loc.T("preferences.play_from_that_point")),
+ F(Loc.T("preferences.click_wave_spec"), Loc.T("preferences.switch_the_well_between_the")),
+ F(Loc.T("preferences.scroll_on_the_track_button"), Loc.T("preferences.step_through_the_demo_tracks")),
+ F(Loc.T("preferences.alt_click_volume"), Loc.T("preferences.type_the_preview_volume_double")),
+ ]));
+ groups.Add(new(Loc.T("preferences.gamepad_macos"),
+ [
+ F(Loc.T("preferences.face_buttons"), Loc.T("preferences.play_c4_d4_e4_f4")),
+ F(Loc.T("preferences.shoulder_buttons"), Loc.T("preferences.play_g4_a4_b4_c5")),
+ F("D-pad ↑ / ↓", Loc.T("preferences.shift_the_gamepad_octave")),
+ F("D-pad ← / →", Loc.T("preferences.lower_raise_velocity")),
+ F(Loc.T("preferences.any_button"), Loc.T("preferences.mappable_through_midi_learn_a")),
+ F(Loc.T("preferences.sticks_triggers"), Loc.T("preferences.mappable_as_continuous_controls_a")),
+ ]));
+ groups.Add(new(Loc.T("preferences.mouse"), MouseRows()));
+ return groups;
+ }
+
+ private static ShortcutRow F(string key, string text) => new(null, key, text);
+
+ private static List<ShortcutRow> MouseRows() =>
+ [
+ F(Loc.T("preferences.double_click_clip"), Loc.T("preferences.open_in_the_clip_editor")),
+ F(Loc.T("preferences.double_click_a_track_header"), Loc.T("preferences.open_its_devices_in_the")),
+ F(Loc.T("preferences.double_click_a_browser_instrument"), Loc.T("preferences.swap_it_onto_the_selected")),
+ F(Loc.T("preferences.alt_double_click_a_browser"), Loc.T("preferences.always_start_a_new_track")),
+ F(Loc.T("preferences.right_click_the_metronome"), Loc.T("preferences.count_in_before_play_record")),
+ F(Loc.T("preferences.drag_an_audio_clips_adsr"), Loc.T("preferences.shape_attack_decay_sustain_release")),
+ F(Loc.T("preferences.click_track_header"), Loc.T("preferences.add_the_track_to_the")),
+ F(Loc.T("preferences.click_a_groups_link_key"), Loc.T("preferences.link_the_groups_tracks_arming")),
+ F(Loc.T("preferences.click_a_clip_or_arm"), Loc.T("preferences.in_a_linked_group_select")),
+ F(Loc.T("preferences.right_click_track_headers"), Loc.T("preferences.a_multi_selection_gets_its")),
+ F(Loc.T("preferences.drag_a_tracks_bottom_edge"), Loc.T("preferences.resize_the_track_header_or")),
+ F(Loc.T("preferences.drag_a_tracks_bottom_edge_2"), Loc.T("preferences.resize_every_track_at_once")),
+ F(Loc.T("preferences.double_click_a_tracks_bottom"), Loc.T("preferences.back_to_the_standard_height")),
+ F(Loc.T("preferences.drag_a_returns_or_the"), Loc.T("preferences.resize_that_row_header_or")),
+ F("⌘-click / ⇧-click return headers", Loc.T("preferences.select_several_returns_they_resize")),
+ F(Loc.T("preferences.click_a_height_key_in"), Loc.T("preferences.set_every_track_to_compact")),
+ F(Loc.T("preferences.drag_the_track_list_edge"), Loc.T("preferences.widen_or_narrow_the_track")),
+ F(Loc.T("preferences.drag_sections_lane"), Loc.T("preferences.mark_a_new_section_over")),
+ F(Loc.T("preferences.click_section"), Loc.T("preferences.jump_the_playhead_to_its")),
+ F(Loc.T("preferences.double_click_section"), Loc.T("preferences.rename_it_right_click_reset")),
+ F(Loc.T("preferences.return_esc_renaming_a_section"), Loc.T("preferences.keep_the_name_empty_automatic")),
+ F(Loc.T("preferences.drag_section"), Loc.T("preferences.rearrange_the_song_it_and")),
+ F(Loc.T("preferences.drag_section_2"), Loc.T("preferences.move_only_the_section_marker")),
+ F(Loc.T("preferences.drag_section_edge"), Loc.T("preferences.resize_it_snapped_to_bars")),
+ F(Loc.T("preferences.right_click_section"), Loc.T("preferences.move_earlier_later_duplicate_or")),
+ F(Loc.T("preferences.drag_overview_strip"), Loc.T("preferences.drag_sideways_to_scroll_up")),
+ F(Loc.T("preferences.drag_overview_edge"), Loc.T("preferences.zoom_by_resizing_the_viewport")),
+ F(Loc.T("preferences.double_click_overview"), Loc.T("preferences.fit_the_whole_project_on")),
+ F(Loc.T("preferences.drag_a_device_header"), Loc.T("preferences.reorder_devices_or_right_click")),
+ F(Loc.T("preferences.right_click_a_device_header"), Loc.T("preferences.a_b_compare_move_copy")),
+ F(Loc.T("preferences.delete_device_selected"), Loc.T("preferences.remove_the_selected_device_the")),
+ F(Loc.T("preferences.drag_an_audio_clip_onto"), Loc.T("preferences.load_its_audio_into_the")),
+ F(Loc.T("preferences.drag_an_audio_clip_out"), Loc.T("preferences.take_it_as_a_sample")),
+ F(Loc.T("preferences.drag_clip_2"), Loc.T("preferences.position_freely_ignoring_the_grid")),
+ F(Loc.T("preferences.wheel_over_the_device_chain"), Loc.T("preferences.scroll_it_sideways_over_an")),
+ F(Loc.T("preferences.drag_knob"), Loc.T("preferences.change_a_device_value_hold")),
+ F(Loc.T("preferences.drag_slider"), Loc.T("preferences.left_right_or_up_down")),
+ F(Loc.T("preferences.click_a_knob_fader_or"), Loc.T("preferences.type_a_value_units_like")),
+ F(Loc.T("preferences.return_esc_tab_tab_typing"), Loc.T("preferences.set_it_cancel_set_it")),
+ F(Loc.T("preferences.click_a_graph_handle_envelope"), Loc.T("preferences.type_its_values_a_node")),
+ F(Loc.T("preferences.double_click_a_knob_fader"), Loc.T("preferences.reset_the_value_to_its")),
+ F(Loc.T("preferences.double_click_a_mod_matrix"), Loc.T("preferences.clear_the_route_volt_aurora")),
+ F(Loc.T("preferences.right_click_a_knob_fader"), Loc.T("preferences.type_value_reset_to_default")),
+ F(Loc.T("preferences.drag_jack_jack"), Loc.T("preferences.patch_a_cable_in_nota")),
+ F(Loc.T("preferences.click_a_rhythm_step"), Loc.T("preferences.step_on_off_accent_quiet")),
+ F(Loc.T("preferences.click_a_rhythm_voice"), Loc.T("preferences.select_and_play_it_drop")),
+ ];
+}
diff --git a/src/managed/Nota.Application/Localization/en.json b/src/managed/Nota.Application/Localization/en.json
index 641a32a7..94fb7222 100644
--- a/src/managed/Nota.Application/Localization/en.json
+++ b/src/managed/Nota.Application/Localization/en.json
@@ -2264,6 +2264,95 @@
"history.what_changed_in_this_version": "What changed in this version?",
"key_picker.pick_a_note_for_the_key": "Pick a note for the key",
"key_picker.relative": "Relative {0}",
+ "keys.arr_move_to_track_down": "Move the selected clips to the track below",
+ "keys.arr_move_to_track_up": "Move the selected clips to the track above",
+ "keys.arr_nudge_fine_left": "Nudge the selected clips left by a 64th",
+ "keys.arr_nudge_fine_right": "Nudge the selected clips right by a 64th",
+ "keys.arr_nudge_left": "Nudge the selected clips left by the grid",
+ "keys.arr_nudge_right": "Nudge the selected clips right by the grid",
+ "keys.browser_back": "Back in the browse view",
+ "keys.browser_edit_path": "Type or paste a path",
+ "keys.browser_forward": "Forward in the browse view",
+ "keys.browser_up": "Up to the parent folder",
+ "keys.devices_group": "Group the selected devices into a rack",
+ "keys.devices_ungroup": "Take the devices out of their rack",
+ "keys.edit_cancel": "Cancel the gesture or clear the selection",
+ "keys.fixed.alt_tap_opens_the_menu": "Press and release on its own: open the menu",
+ "keys.fixed.pan_the_canvas": "Pan the canvas",
+ "keys.fixed.space_drag": "Hold Space + drag",
+ "keys.group.arrangement": "Arrangement",
+ "keys.group.browser": "Browser files",
+ "keys.group.devices": "Devices",
+ "keys.group.modular": "Modular",
+ "keys.group.notes": "Play notes (computer keyboard)",
+ "keys.modular_bypass": "Bypass the selected device",
+ "keys.modular_fit": "Fit every node on screen",
+ "keys.notes_a": "A",
+ "keys.notes_as": "A♯",
+ "keys.notes_b": "B",
+ "keys.notes_c": "C",
+ "keys.notes_c2": "C an octave up",
+ "keys.notes_cs": "C♯",
+ "keys.notes_d": "D",
+ "keys.notes_ds": "D♯",
+ "keys.notes_e": "E",
+ "keys.notes_f": "F",
+ "keys.notes_fs": "F♯",
+ "keys.notes_g": "G",
+ "keys.notes_gs": "G♯",
+ "keys.notes_octave_down": "Octave down",
+ "keys.notes_octave_up": "Octave up",
+ "keys.notes_velocity_down": "Lower the velocity",
+ "keys.notes_velocity_up": "Raise the velocity",
+ "keys.roll_lengthen": "Lengthen the notes by the grid",
+ "keys.roll_move_left": "Move notes left by the grid",
+ "keys.roll_move_right": "Move notes right by the grid",
+ "keys.roll_shorten": "Shorten the notes by the grid",
+ "keys.roll_transpose_down": "Transpose down a semitone",
+ "keys.roll_transpose_up": "Transpose up a semitone",
+ "keys.roll_velocity_down": "Velocity −10",
+ "keys.roll_velocity_down_fine": "Velocity −1",
+ "keys.roll_velocity_up": "Velocity +10",
+ "keys.roll_velocity_up_fine": "Velocity +1",
+ "keys.scope.arrangement": "Arrangement",
+ "keys.scope.audio_editor": "audio clip editor",
+ "keys.scope.browser": "Files browser",
+ "keys.scope.devices": "device chain",
+ "keys.scope.global": "everywhere",
+ "keys.scope.modular": "Modular canvas",
+ "keys.scope.notes": "computer-keyboard notes",
+ "keys.scope.piano_roll": "piano roll",
+ "keys.scope.session": "Session grid",
+ "keys.session_launch_selection": "Launch the selected clip or scene",
+ "keys.session_rename": "Rename the selected clip or scene",
+ "keys.ui.add_alternative": "Add an alternative key",
+ "keys.ui.already_this_action": "{0} is already this action's other key.",
+ "keys.ui.assign_esc": "Assign Esc",
+ "keys.ui.click_to_change": "Click to change",
+ "keys.ui.confirm": "Confirm",
+ "keys.ui.default": "default",
+ "keys.ui.default_taken": "Its default {0} is now {1}. Pick another key, reset it to take {0} back, or leave it unassigned.",
+ "keys.ui.edited_only": "Edited only",
+ "keys.ui.fixed": "This key belongs to the system.",
+ "keys.ui.how_to_edit": "Click a key to change it, press the new combination, then Confirm. Esc cancels. Keys other apps take over the whole system can't be detected.",
+ "keys.ui.leave_unassigned": "Leave unassigned",
+ "keys.ui.navigation": "{0} moves the selection here, so it can't be rebound.",
+ "keys.ui.needs_decision": "Needs a decision",
+ "keys.ui.nothing_edited": "No shortcut differs from its default.",
+ "keys.ui.press_a_shortcut": "Press a shortcut…",
+ "keys.ui.replace": "Replace",
+ "keys.ui.reserved": "{0} is kept by {1}.",
+ "keys.ui.reset_all": "Reset all to defaults…",
+ "keys.ui.reset_all_confirm": "Reset all",
+ "keys.ui.reset_all_message": "Every custom key is replaced by its default. This can't be undone.",
+ "keys.ui.reset_all_title": "Reset all shortcuts?",
+ "keys.ui.reset_to_default": "Reset to default",
+ "keys.ui.shadow": "Elsewhere {0} is {1} — in the {2} this one wins.",
+ "keys.ui.shadowed": "In the {2} {0} is {1}, which wins there while it has the keyboard.",
+ "keys.ui.unsupported_key": "Nota can't use that key — try a letter, digit, function key or arrow.",
+ "keys.ui.used_by": "{0} is used by {1} ({2}).",
+ "keys.view_cycle_detail_tab": "Cycle the detail panel's Devices / Pattern / Clip tabs",
+ "keys.view_open_menu": "Open the menu",
"kits.drum_kit.couldnt_create_a_drum_rack": "Couldn't create a Drum Rack track.",
"kits.drum_kit.couldnt_create_a_nota_rhythm": "Couldn't create a Nota Rhythm track.",
"kits.drum_kit.unknown_drum_kit": "Unknown drum kit.",
@@ -3359,7 +3448,6 @@
"preferences.apply_and_keep_the_palette": "Apply and keep the palette open for the next device",
"preferences.apply_where_the_palette_was": "Apply where the palette was opened (the target shows in the field)",
"preferences.arrangement": "Arrangement",
- "preferences.arrangement_editing": "Arrangement & editing",
"preferences.asio_caps": "ASIO",
"preferences.asio_device_on_audio": "{0} — the ASIO driver is both input and output.",
"preferences.asio_frames": "ASIO · {0} frames @ {1}{2}",
@@ -3371,16 +3459,11 @@
"preferences.audio_settings_are_unavailable_in": "Audio settings are unavailable in this window.",
"preferences.audio_subtitle": "Sample rate, buffer and latency",
"preferences.audio_system": "Audio system",
- "preferences.back_forward_in_the_browse": "Back · forward through the folders you opened (Browse)",
"preferences.back_to_the_standard_height": "Back to the standard height",
"preferences.bars": "Bars",
"preferences.bend_range": "Bend range",
- "preferences.black_keys_sharps": "Black keys (sharps)",
- "preferences.browser_files_after_a_click": "Browser · Files (after a click in its list)",
"preferences.browser_preview": "Browser · preview",
"preferences.buffer_size": "Buffer size",
- "preferences.bypass_the_selected_device": "Bypass the selected device",
- "preferences.cancel_the_current_gesture_clear": "Cancel the current gesture / clear the selection · close the patch-bay overlay",
"preferences.change_a_device_value_hold": "Change a device value · hold ⌘ or ⇧ for fine steps",
"preferences.change_its_velocity_the_whole": "Change its velocity · the whole selection's when the note is selected · elsewhere scroll sideways",
"preferences.change_on_audio_page": "Change on the Audio page",
@@ -3389,7 +3472,6 @@
"preferences.choose": "Choose…",
"preferences.choose_folder": "Choose {0} folder",
"preferences.choose_lane_controller": "Choose a CC, the pitch wheel or channel pressure for that lane",
- "preferences.clear_the_device_selection_so": "Clear the device selection · so does a click on the chain's empty space",
"preferences.clear_the_route_volt_aurora": "Clear the route (Volt, Aurora) · pull the cable (Consort)",
"preferences.click_a_clip_in_the": "Click a clip in the clip strip",
"preferences.click_a_clip_or_arm": "⌥-click a clip or Arm",
@@ -3421,7 +3503,6 @@
"preferences.cmd_alt_wheel": "⌘⌥ + wheel",
"preferences.colour_theme": "Colour theme",
"preferences.command_palette": "Command palette",
- "preferences.consolidate_the_selection_into_one": "Consolidate the selection into one clip per track",
"preferences.content_folders": "Content folders",
"preferences.content_folders_and_version_history": "Content folders and version history",
"preferences.content_folders_are_unavailable_in": "Content folders are unavailable in this window.",
@@ -3429,39 +3510,21 @@
"preferences.controllers_nota_listens_to": "Controllers Nota listens to",
"preferences.copied": "Copied",
"preferences.copy_config": "Copy config",
- "preferences.copy_cut_paste_a_clip": "Copy / cut / paste a clip · a cut clip moves when pasted · clips copied in the Arrangement paste here",
- "preferences.copy_cut_paste_clips_a": "Copy / cut / paste clips, a time range or an automation range · pastes onto the track clicked last",
- "preferences.copy_cut_paste_notes_paste": "Copy / cut / paste notes · paste lands on the originals",
- "preferences.copy_cut_paste_the_selected": "Copy / cut / paste the selected devices with all their settings · each lands in its section after the selected device · a copied instrument replaces the instrument it is pasted on",
- "preferences.copy_cut_paste_the_selected_2": "Copy / cut / paste the selected tracks · paste lands after the last one",
"preferences.copy_it_there": "Copy it there",
- "preferences.copy_the_selected_clip_group": "Copy the selected clip, group slot or scene to the Arrangement at the playhead",
- "preferences.copy_the_selected_clips_to": "Copy the selected clips to Session · the first scene row where they fit",
"preferences.couldnt_be_loaded_see_plugin": " {0:N0} couldn't be loaded — see plugin-scan.log in Nota's logs folder.",
"preferences.count_in_before_play_record": "Count-in before Play / Record: off · 1 · 2 · 4 bars",
"preferences.cpu_check": "CPU check",
"preferences.custom": "custom",
- "preferences.cycle_devices_pattern_clip_in": "Cycle Devices / Pattern / Clip in the detail panel",
"preferences.d_pad_left_right": "D-pad left / right",
"preferences.d_pad_up_down": "D-pad up / down",
"preferences.dark": "Dark",
- "preferences.deactivate_activate_the_selected_clip": "Deactivate / activate the selected clip(s)",
"preferences.default": "default",
"preferences.default_unavailable": "default · unavailable",
"preferences.delete_device_selected": "Delete (device selected)",
- "preferences.delete_the_selected_clip_or": "Delete the selected clip or scene",
- "preferences.delete_the_selected_clip_range": "Delete the selected clip / range",
- "preferences.delete_the_selected_device_modulator": "Delete the selected device, modulator or cable · the track's input, instrument and output are fixed",
- "preferences.delete_the_selected_devices_with": "Delete the selected devices · with the instrument, its track",
- "preferences.delete_the_selected_notes": "Delete the selected notes",
- "preferences.delete_the_selected_tracks_a": "Delete the selected tracks · a group goes with its tracks",
- "preferences.deselect_moved_or_pasted_notes": "Deselect · moved or pasted notes replace the notes under them",
"preferences.detail_panel": "Detail panel",
"preferences.device_default": "Device default",
- "preferences.devices_after_a_click_on": "Devices (after a click on a device)",
"preferences.devices_settings": "Devices",
"preferences.direction": "Direction",
- "preferences.discard_the_take_and_record": "Discard the take being recorded and record it again · Arrangement: from where it started, counting in again · Session: from the next launch quantum",
"preferences.double_click_a_browser_instrument": "Double-click a browser instrument",
"preferences.double_click_a_chain_or": "Double-click a chain or macro name",
"preferences.double_click_a_knob_fader": "Double-click a knob, fader or slider",
@@ -3528,34 +3591,21 @@
"preferences.driver": "Driver",
"preferences.driver_settings": "Driver settings…",
"preferences.dropouts": { "one": "{0} dropout", "other": "{0} dropouts" },
- "preferences.duplicate_a_clip_into_the": "Duplicate a clip into the slot below · a scene below itself",
- "preferences.duplicate_the_selected_clip_s": "Duplicate the selected clip(s) / range",
- "preferences.duplicate_the_selected_device_with": "Duplicate the selected device with all its settings",
- "preferences.duplicate_the_selected_devices_each": "Duplicate the selected devices · each run right after itself",
- "preferences.duplicate_the_selected_tracks": "Duplicate the selected tracks",
- "preferences.duplicate_the_selection_replaces_the": "Duplicate the selection · replaces the notes it lands on",
- "preferences.duplicate_time_insert_a_copy": "Duplicate time · insert a copy of the time range after it, pushing everything later right",
"preferences.edit_the_clip_an_empty": "Edit the clip · an empty MIDI slot gets a new clip",
"preferences.editing": "Editing",
"preferences.editing_subtitle": "Piano roll, arrangement and the detail panel",
"preferences.enable_mcp_server_let_an": "Enable MCP server (let an AI drive Nota)",
- "preferences.end_macro_mapping_map_on": "End macro mapping (Map on the rack card)",
- "preferences.enter_leave_full_screen_the": "Enter / leave full screen — the title bar hides in full screen",
"preferences.every_save_records_a_version": "Every save records a version, listed in the browser's History tab. Versions share their audio, so each one costs only what it adds.",
"preferences.exclusive": "exclusive",
"preferences.exclusive_mode": "Exclusive mode",
"preferences.exclusive_refused_shared": "exclusive refused → shared",
- "preferences.export_audio": "Export audio",
"preferences.expression": "Expression",
"preferences.extra_folders_are_searched_for": "Extra folders are searched for VST3 plugins on the next rescan (AU uses the system registry).",
"preferences.face_buttons": "Face buttons",
"preferences.fade_audio_clips_when_splitting": "Fade audio clips when splitting",
"preferences.filter_all_actions_tracks_devices": "Filter: all · actions · tracks · devices · presets",
"preferences.filter_shortcuts": "Filter shortcuts",
- "preferences.fit_every_node_on_screen": "Fit every node on screen",
"preferences.fit_the_whole_project_on": "Fit the whole project on screen",
- "preferences.fit_to_notes": "Fit to notes",
- "preferences.fold_only_the_scales_notes": "Fold: only the scale's notes, or a Drum Rack's pads",
"preferences.follow_system": "Follow system",
"preferences.found_plugins": { "one": "Found {0:N0} plugin.", "other": "Found {0:N0} plugins." },
"preferences.frames": "{0} frames @ {1}{2}",
@@ -3566,16 +3616,12 @@
"preferences.gamepad_settings_are_unavailable_in": "Gamepad settings are unavailable in this window.",
"preferences.gamepads": "Gamepads",
"preferences.general": "General",
- "preferences.grid_arrangement_or_clip_editor": "Grid (Arrangement or clip editor — whichever you used last)",
- "preferences.group_the_selected_devices_into": "Group the selected devices into a rack · audio effects: Audio Effect Rack · MIDI effects: MIDI Effect Rack · with the instrument: Instrument Rack",
- "preferences.group_ungroup_selected_tracks_on": "Group / ungroup selected tracks · on selected devices: group them into a rack / take a rack apart",
"preferences.hover_the_zones": "Hover the zones",
"preferences.how_audio_clips_draw_on": "How audio clips draw on the arrangement: Smooth outlines the peaks around the RMS level; Solid draws every pixel; Bars spaces the peaks out so the rhythm reads. Solid and Bars also set the browser's preview.",
"preferences.hz_sine_at_14_dbfs": "{0:0} Hz sine at −14 dBFS, through the master.",
"preferences.in_a_linked_group_select": "In a linked group: select that clip alone, or arm that track alone",
"preferences.in_dark_mode": "In dark mode",
"preferences.in_light_mode": "In light mode",
- "preferences.in_the_xl_panel_return": "In the XL panel (EQ-8, Dynamic EQ-8): return the device to L, as Shrink in its header",
"preferences.inputs": "Inputs",
"preferences.inputs_hint": "Switch off the inputs you don't use and name the rest: track input menus list only the inputs that are on, under these names. Kept for this device.",
"preferences.inputs_no_device": "No input device: choose one above, or connect one.",
@@ -3590,7 +3636,6 @@
"preferences.menu_bar_caption": "The row of File, Edit, View… under the title bar. Hidden, the whole menu is under the Menu key at the start of the transport bar, and Alt or F10 opens it. Also in the View menu.",
"preferences.menu_bar_hidden": "Hidden",
"preferences.menu_bar_shown": "Shown",
- "preferences.open_the_menu": "Open the menu (Windows, Linux)",
"preferences.open_the_selected_folder_browse": "Open the selected folder (Browse)",
"preferences.outputs_pairs": "Output pairs",
"preferences.outputs_click": "Click",
@@ -3610,8 +3655,6 @@
"preferences.outputs_no_device": "No output device: choose one above, or connect one.",
"preferences.outputs_pair": "Out {0}/{1}",
"preferences.outputs_single": "Out {0}",
- "preferences.insert_a_scene_below_the": "Insert a scene below the selection",
- "preferences.insert_silence_push_everything_from": "Insert silence · push everything from the range start right by its length",
"preferences.install": "Install",
"preferences.installed": "Installed",
"preferences.installed_to": "Installed to {0}",
@@ -3620,7 +3663,7 @@
"preferences.jump_the_playhead_to_its": "Jump the playhead to its start",
"preferences.keep_a_version_history_of": "Keep a version history of each project",
"preferences.keep_the_name_empty_automatic": "Keep the name (empty = automatic) · cancel",
- "preferences.keyboard_reference": "Keyboard reference",
+ "preferences.shortcuts_subtitle": "Your keys, and the mouse for reference",
"preferences.label_every_note_in_the": "Label every note in the piano roll",
"preferences.language": "Language",
"preferences.language.and_more_see_the_log": "…and {0} more (see the log)",
@@ -3649,7 +3692,6 @@
"preferences.last": "Last",
"preferences.last_check_average_peak": "Last check: {0:0} % average, {1:0} % peak · {2} — {3}.",
"preferences.latency": "Latency",
- "preferences.launch_the_selected_clip_or": "Launch the selected clip or scene",
"preferences.layout": "Layout",
"preferences.left": "Left",
"preferences.left_right_or_up_down": "Left / right (or up / down) changes the value · hold ⌘ or ⇧ for fine steps",
@@ -3659,9 +3701,7 @@
"preferences.listening_on_http_127_0": "Listening on http://127.0.0.1:{0}/ (loopback)",
"preferences.load_its_audio_into_the": "Load its audio into the Sampler, Grain, Drum Rack (next free pad) or Instrument Rack · rest there to open its devices",
"preferences.loop_on_off_in_the": "Loop on / off in the ruler · the region stays, greyed out while off",
- "preferences.loop_on_off_loop_the": "Loop on / off · loop the selected clips or time range",
"preferences.loop_on_off_loop_the_2": "Loop on / off · loop the selection · clear the loop region",
- "preferences.loop_recording_overdub_every_pass": "Loop recording: Overdub (every pass adds) / Replace (keep the latest pass)",
"preferences.lower_raise_velocity": "Lower / raise velocity",
"preferences.make_it_the_active_clip": "Make it the active clip (several clips open) · its lock keeps it as a read-only reference",
"preferences.makes_the_whole_interface_larger": "Makes the whole interface larger or smaller. Timeline, piano roll and audio editor zoom work on top of it.",
@@ -3689,25 +3729,20 @@
"preferences.models.remove_will_offer_to_download": "Remove {0}? {1} will offer to download it again.",
"preferences.models.removing": "Removing…",
"preferences.models.the_ai_runtime_goes_too": " The AI runtime goes too.",
- "preferences.modular_after_a_click_on": "Modular (after a click on the canvas)",
"preferences.mouse": "Mouse",
"preferences.move_earlier_later_duplicate_or": "Move earlier / later · duplicate or delete with content",
"preferences.move_freely_ignoring_the_grid": "Move freely, ignoring the grid",
"preferences.move_it_there_out_of": "Move it there (out of the panel, onto a track row or Session column) · the instrument replaces that track's and its own track goes",
"preferences.move_it_to_another_slot": "Move it to another slot · ⌥ copies",
"preferences.move_it_within_its_chain": "Move it within its chain · onto another chain's row to move it there",
- "preferences.move_notes_by_the_grid": "Move notes by the grid",
"preferences.move_only_the_section_marker": "Move only the section marker, snapped to bars",
"preferences.move_the_clips_to_a": "Move the clips to a new track like their own · one per source track",
"preferences.move_the_playhead_there_drag": "Move the playhead there · drag to scrub · snapped to the grid on a warped clip, ⌥ off it",
"preferences.move_the_playhead_there_drag_2": "Move the playhead there · drag to scrub, snapped to the grid · ⌥ off the grid",
- "preferences.move_the_selected_clips_to": "Move the selected clips to the next track that takes them, at the same beats",
"preferences.move_the_selected_devices_of": "Move the selected devices of that section together",
"preferences.move_the_selection_between_slots": "Move the selection between slots and scenes",
"preferences.move_through_samples_presets_and": "Move through samples, presets and devices · with Auto on, each one plays as it is selected",
"preferences.move_through_the_results": "Move through the results",
- "preferences.narrow_widen_the_grid_in": "Narrow / widen the grid · in Auto, change the density",
- "preferences.new_project_open_a_project": "New project / open a project",
"preferences.new_versions_of_nota": "New versions of Nota",
"preferences.no_asio_driver_found_few": "No ASIO driver found. Few interfaces ship an ARM64 ASIO driver yet — install one from your interface's maker, or a generic one such as FlexASIO.",
"preferences.no_asio_driver_found_install": "No ASIO driver found. Install your interface's driver, or a generic one such as FlexASIO.",
@@ -3717,11 +3752,8 @@
"preferences.nota_synth_volt_aurora_operator": "Nota Synth, Volt, Aurora, Operator, Pentad and Physical play per-note expression.",
"preferences.notes_go_to_the_armed": "Notes go to the armed (record-enabled) instrument track — enable Record to capture them, or use the audition track to just play.",
"preferences.nothing_matches": "Nothing matches.",
- "preferences.nudge_the_selected_clips_by": "Nudge the selected clips by a 64th note",
- "preferences.nudge_the_selected_clips_by_2": "Nudge the selected clips by the grid step · stops at the song start",
"preferences.octave_1_1": "Octave −1 / +1",
"preferences.off_a_click_only_selects": "Off: a click only selects, and an open panel follows it. Double-click a track for its devices or a clip to edit it.",
- "preferences.open_close_the_command_palette": "Open / close the command palette — from any window, even while typing",
"preferences.open_in_the_clip_editor": "Open in the clip editor, opening the detail panel · on one of several selected MIDI clips, open them all together",
"preferences.open_its_devices_in_the": "Open its devices in the detail panel · a plug-in's own window is Open editor on its card",
"preferences.open_plug_in_window_on": "Open plug-in window on insert",
@@ -3730,7 +3762,6 @@
"preferences.outputs": "Outputs",
"preferences.outputs_subtitle": "Where Nota plays, and the test tone",
"preferences.overloaded_raise_the_buffer_size": "overloaded — raise the buffer size",
- "preferences.paste_the_last_range_as": "Paste the last range as audio rendered through its devices",
"preferences.patch_a_cable_in_nota": "Patch a cable in Nota Consort · ⌥-click a jack to pull its cables",
"preferences.per_note_expression_from_mpe": "Per-note expression from MPE controllers",
"preferences.performance": "Performance",
@@ -3742,10 +3773,7 @@
"preferences.play_from_that_point": "Play from that point",
"preferences.play_g4_a4_b4_c5": "Play G4 A4 B4 C5",
"preferences.play_it_on_the_tracks": "Play it on the track's instrument · ⇧-drag glides through the keys · ⌘-click selects every note of that pitch",
- "preferences.play_notes_computer_keyboard": "Play notes (computer keyboard)",
"preferences.play_notes_or_drive_mapped": "Play notes or drive mapped controls",
- "preferences.play_pause_the_playhead_stays": "Play / pause · the playhead stays put and Play carries on from there",
- "preferences.play_stop_stop_goes_back": "Play / Stop · Stop goes back to where playback started",
"preferences.play_stop_the_selected_sample": "Play / stop the selected sample, preset or device",
"preferences.play_test_tone": "Play test tone",
"preferences.plenty_of_headroom": "plenty of headroom",
@@ -3758,7 +3786,6 @@
"preferences.position_freely_ignoring_the_grid": "Position freely, ignoring the grid for this drag (the magnet in the transport latches the same thing)",
"preferences.projects": "Projects",
"preferences.put_the_note_back_to": "Put the note back to the default velocity (0.8) · the whole selection's when the note is selected · undo is one step",
- "preferences.quit_nota_asks_about_unsaved": "Quit Nota · asks about unsaved changes first",
"preferences.racks": "Racks",
"preferences.rearrange_the_song_it_and": "Rearrange the song · it and everything in it move to the marked boundary, the sections between close up · Esc cancels",
"preferences.refresh": "Refresh",
@@ -3800,7 +3827,6 @@
"preferences.removing": "Removing {0}…",
"preferences.rename_it": "Rename it",
"preferences.rename_it_right_click_reset": "Rename it · right-click → Reset to default name for its automatic Section N",
- "preferences.rename_the_selected_clip_or": "Rename the selected clip or scene",
"preferences.rename_the_track": "Rename the track",
"preferences.reorder_devices_or_right_click": "Reorder devices (or right-click the header → Move left / right)",
"preferences.reorder_scenes": "Reorder scenes",
@@ -3846,8 +3872,6 @@
"preferences.samples.samples": { "one": "{0} sample", "other": "{0} samples" },
"preferences.samples.samples_n": "{0} · {1} samples",
"preferences.samples.show_the_packs_folder": "Show the pack's folder",
- "preferences.save_a_version_with_a": "Save a version with a note",
- "preferences.save_records_a_version_save": "Save (records a version) / save as",
"preferences.saved_driver_not_found": "Saved driver not found",
"preferences.scan": "Scan",
"preferences.scanner_worker_not_found": "Scanner worker not found.",
@@ -3861,14 +3885,10 @@
"preferences.see_which_chains_a_note": "See which chains a note would play",
"preferences.select_a_range_of_devices": "Select a range of devices (MIDI effects, instrument, audio effects) / add or remove one",
"preferences.select_a_range_of_tracks": "Select a range of tracks / add or remove one track",
- "preferences.select_all_clips": "Select all clips",
- "preferences.select_all_notes": "Select all notes",
- "preferences.select_all_tracks": "Select all tracks",
"preferences.select_and_play_it_drop": "Select and play it · drop a file on it to load a sample",
"preferences.select_it_for_c_x": "Select it for ⌘C ⌘X ⌘V ⌘D and Delete",
"preferences.select_several_returns_they_resize": "Select several returns · they resize together",
"preferences.semitones": "±{0} semitones",
- "preferences.session_after_a_click_in": "Session (after a click in the grid)",
"preferences.set_a_chains_key_velocity": "Set a chain's key, velocity or select range · edges never cross",
"preferences.set_every_track_to_compact": "Set every track to Compact · Standard · Large",
"preferences.set_in_the_drivers_settings": "Set in the driver's settings",
@@ -3877,13 +3897,9 @@
"preferences.set_velocity_selected_notes_move": "Set velocity · selected notes move together · ⇧ adds a note",
"preferences.shape_attack_decay_sustain_release": "Shape attack · decay + sustain · release (top corners and the dot on hover) · ⌥-click types the stage · double-click resets it",
"preferences.shape_the_new_note_move": "Shape the new note: move it · ⇧ set its length · ⌘ drag up / down for velocity",
- "preferences.shift_octave_down_up": "Shift octave down / up",
"preferences.shift_the_gamepad_octave": "Shift the gamepad octave",
"preferences.shortcuts": "Shortcuts",
- "preferences.shorten_lengthen_the_notes_by": "Shorten / lengthen the notes by the grid",
"preferences.shoulder_buttons": "Shoulder buttons",
- "preferences.show_fewer_parameters_on_every": "Show fewer parameters on every opened node",
- "preferences.show_playhead_scroll_the_arrangement": "Show playhead · scroll the Arrangement to it without moving it · picks up a paused Follow",
"preferences.show_primary_controller_lane": "Show the primary MIDI controller lane",
"preferences.shows_every_note_name_c": "Shows every note name (C, D, E…) on the piano roll's keys instead of only C. Helpful when learning notes.",
"preferences.skins.cant_save": "Couldn't save the theme: {0}",
@@ -3899,17 +3915,14 @@
"preferences.skins.user_tag": "User theme",
"preferences.skins.warnings": {"one": "{0} warning", "other": "{0} warnings"},
"preferences.smooth": "Smooth",
- "preferences.snap_to_grid_on_off": "Snap to grid on / off",
"preferences.solid": "Solid",
"preferences.source": "Source",
- "preferences.split_at_the_playhead_at": "Split at the playhead · at the range edges",
"preferences.splitting_an_audio_clip_adds": "Splitting an audio clip adds a 4 ms fade at the cut, so it doesn't click. Drag the corner handles on the clip to make it longer or shorter. MIDI clips are left alone.",
"preferences.status": "Status",
"preferences.step": "Step",
"preferences.step_on_off_accent_quiet": "Step on / off · accent · quiet step — drag across to paint, up / down (or scroll) for its velocity",
"preferences.step_through_the_demo_tracks": "Step through the demo tracks an effect preset is heard through",
"preferences.sticks_triggers": "Sticks · triggers",
- "preferences.stop_again_back_to_the": "Stop (again → back to the start) · in the Session grid it launches the selection",
"preferences.stop_tone": "Stop tone",
"preferences.store.apple_silicon": "Apple silicon",
"preferences.store.apple_silicon_intel": "Apple silicon + Intel",
@@ -3934,12 +3947,10 @@
"preferences.store.windows": "Windows",
"preferences.swap_it_onto_the_selected": "Swap it onto the selected instrument track · clips and effects stay · no track selected starts one",
"preferences.switch_a_controller_off_to": "Switch a controller off to stop Nota listening to it. New devices are on by default.",
- "preferences.switch_between_the_adaptive_auto": "Switch between the adaptive (Auto) and a fixed grid",
"preferences.switch_it_between_bars_and": "Switch it between bars and time · every ruler follows",
"preferences.switch_the_well_between_the": "Switch the well between the waveform and a live spectrum",
"preferences.system_default": "System default",
"preferences.take_it_as_a_sample": "Take it as a sample: drop on a pad, a Grain, a Rhythm voice, a Session slot — the clip stays put",
- "preferences.take_the_devices_out_of": "Take the devices out of a selected one-chain rack",
"preferences.test": "Test",
"preferences.text_size": "Text size",
"preferences.text_size_caption": "Makes the text larger or smaller without changing the layout. Long labels may shorten with an ellipsis at the larger sizes.",
@@ -3947,29 +3958,19 @@
"preferences.text_size_larger": "Larger",
"preferences.text_size_largest": "Largest",
"preferences.text_size_smaller": "Smaller",
- "preferences.the_clip_editor_fills_the": "The clip editor fills the window / back to the split it had",
"preferences.the_devices_native_sample_rate": "The device's native sample rate and buffer size are used instead of the ones above. If it is busy or doesn't allow exclusive access, Nota falls back to shared mode.",
"preferences.the_driver_didnt_start": "the driver didn't start",
"preferences.the_driver_doesnt_support": "The driver doesn't support {0}",
"preferences.the_language_of_menus_panels": "The language of menus, panels and messages. It changes when Nota restarts. Project files and the names you type are never translated.",
"preferences.this_erases_the_version_history": "This erases the version history of the open project now, and of any other project the next time you save it. Older versions can't be brought back.",
- "preferences.toggle_automation_mode": "Toggle automation mode",
- "preferences.toggle_the_mixer_view": "Toggle the Mixer view",
"preferences.track_headers": "Track headers",
- "preferences.tracks_after_a_click_in": "Tracks (after a click in the track headers)",
- "preferences.transpose_by_a_semitone": "Transpose by a semitone",
- "preferences.transpose_by_an_octave": "Transpose by an octave",
- "preferences.triplet_grid_on_off": "Triplet grid on / off",
"preferences.turn_off_and_erase": "Turn off and erase",
"preferences.turn_off_version_history": "Turn off version history",
"preferences.type_a_value_units_like": "Type a value (units like k, ms, dB, L / R work) · double-click its value does the same",
"preferences.type_first_to_filter_actions": "Type first to filter: actions, tracks, devices, presets, Modular nodes",
"preferences.type_its_values_a_node": "Type its values — a node with several (frequency · gain · Q, decay · sustain) takes Tab between them",
- "preferences.type_or_paste_a_path": "Type or paste a path to open (switches to Browse)",
"preferences.type_the_preview_volume_double": "Type the preview volume · double-click resets it to 0 dB",
"preferences.type_value_reset_to_default": "Type value… · Reset to default",
- "preferences.undo_redo": "Undo / redo",
- "preferences.up_to_the_parent_folder": "Up to the folder above, then to the drives (Browse)",
"preferences.update_to": "Update to {0}",
"preferences.updates": "Updates",
"preferences.updates.automatic_updates": "Automatic updates",
@@ -3992,7 +3993,6 @@
"preferences.updates.you_have_nota": "You have Nota {0}.",
"preferences.use_a_connected_gamepad_for": "Use a connected gamepad for notes and mapped controls",
"preferences.velocity": "Velocity − / +",
- "preferences.velocity_10_10_by_1": "Velocity +10 / −10 · ⌥⇧ by 1",
"preferences.velocity_wheel": "Velocity wheel",
"preferences.version_history": "Version history",
"preferences.was_removed": "{0} was removed.",
@@ -4004,10 +4004,7 @@
"preferences.wheel_up_lowers_the_velocity": "Wheel up lowers the velocity",
"preferences.where_nota_looks_for_vst3": "Where Nota looks for VST3",
"preferences.which_side_of_the_arrangement": "Which side of the arrangement the track list sits on. Right starts the timeline at the left edge, next to the browser. Also in the View menu.",
- "preferences.while_dragging_a_warp_marker": "While dragging a warp marker or a segment tempo: put it back",
- "preferences.white_keys_from_c4": "White keys, from C4",
"preferences.widen_or_narrow_the_track": "Widen or narrow the track headers · double-click resets",
- "preferences.window": "Window",
"preferences.working": "Working…",
"preferences.zoom_by_resizing_the_viewport": "Zoom by resizing the viewport window",
"preferences.zoom_rows_down_taller_up": "Zoom rows · down taller, up shorter",
diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.cs
index f848f0e5..69b19d67 100644
--- a/src/managed/Nota.Application/Settings.cs
+++ b/src/managed/Nota.Application/Settings.cs
@@ -154,6 +154,12 @@ public sealed class Settings
/// <summary>The last items applied from the palette, most recent first (its Recent section).</summary>
public List<string> PaletteRecent { get; set; } = new();
+ // --- keyboard shortcuts (specs/096, #61) ------------------------------------------------
+ /// <summary>The user's custom keys, by key-action id (<see cref="Input.KeyActionCatalog"/>).
+ /// Only actions that differ from their default have an entry, so a new default in a later
+ /// version still reaches everyone who never touched that key.</summary>
+ public Dictionary<string, KeyBindingOverride> KeyBindings { get; set; } = new();
+
/// <summary>Adding a plug-in by hand (browser, drag & drop, palette) opens its editor window
/// right away (#250). On by default; Preferences → Plug-ins.</summary>
public bool OpenPluginWindowOnInsert { get; set; } = true;
@@ -324,3 +330,11 @@ public interface ISettingsService
/// <summary>App-managed presets folder (created). M7-4.</summary>
string PresetsFolder();
}
+
+/// <summary>One action's custom keys (specs/096): per slot, null keeps the default, "" leaves
+/// it unassigned, anything else is the key in glyph notation ("⌘T", "⌥⇧↑", "Q").</summary>
+public sealed class KeyBindingOverride
+{
+ public string? Primary { get; set; }
+ public string? Alternative { get; set; }
+}
diff --git a/src/managed/Nota.Presentation/PaletteProviders.cs b/src/managed/Nota.Presentation/PaletteProviders.cs
index 3fa560b9..07760676 100644
--- a/src/managed/Nota.Presentation/PaletteProviders.cs
+++ b/src/managed/Nota.Presentation/PaletteProviders.cs
@@ -20,7 +20,7 @@ public sealed class ActionPaletteProvider(ICommandRegistry registry) : IPaletteP
.Where(c => c.IsBound && !c.HideInPalette)
.Select(c => new PaletteItem
{
- Kind = PaletteKind.Action, Id = "a:" + c.Id, Name = c.Title, Sub = c.Category, Gesture = c.Gesture,
+ Kind = PaletteKind.Action, Id = "a:" + c.Id, Name = c.Title, Sub = c.Category, Gesture = Nota.Application.Input.KeyBindings.Instance?.Glyphs(c.Id) ?? c.Gesture, // the user's key (specs/096)
View = c.View, Aliases = c.Aliases, Descriptor = c.Descriptor, Payload = c.Id,
}).ToList();
}
diff --git a/tests/Nota.SmokeTest/KeyBindingTests.cs b/tests/Nota.SmokeTest/KeyBindingTests.cs
new file mode 100644
index 00000000..41a26901
--- /dev/null
+++ b/tests/Nota.SmokeTest/KeyBindingTests.cs
@@ -0,0 +1,192 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Custom keyboard shortcuts (specs/096, #61): the key-action catalog, the conflict rule,
+// overrides in settings (only changed slots), reset, and what happens to a user key when a
+// later version ships a default on the same chord.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using Nota.Application;
+using Nota.Application.Input;
+using Nota.Application.Palette;
+
+namespace Nota.SmokeTest;
+
+internal static class KeyBindingTests
+{
+ // The default pairs that share a chord on purpose (research R3): each still works where
+ // it always did. A new pair fails this test until it is added here, deliberately.
+ private static readonly HashSet<string> DefaultPairs = new(StringComparer.Ordinal)
+ {
+ "browser.editPath|transport.loop", // ⌘L: the Files browser's path field while it has focus
+ };
+
+ private const ShortcutModifiers P = ShortcutModifiers.Primary, S = ShortcutModifiers.Shift, A = ShortcutModifiers.Alt;
+
+ public static IEnumerable<(bool, string)> Run()
+ {
+ foreach (bool mac in new[] { true, false })
+ {
+ var catalog = KeyActionCatalog.Create(mac);
+ string os = mac ? "macOS" : "Windows/Linux";
+ var dup = catalog.GroupBy(a => a.Id).Where(g => g.Count() > 1).Select(g => g.Key).ToList();
+ yield return (dup.Count == 0, dup.Count == 0 ? $"{os}: {catalog.Count} key actions, ids unique" : "duplicate key-action ids: " + string.Join(", ", dup));
+ var missing = CommandCatalog.Create().Select(c => c.Id).Where(id => catalog.All(a => a.Id != id)).ToList();
+ yield return (missing.Count == 0, missing.Count == 0 ? $"{os}: every palette command is a key action" : "commands missing: " + string.Join(", ", missing));
+ var badTokens = catalog.SelectMany(a => new[] { a.DefaultPrimary, a.DefaultAlternative }.Where(k => k is not null)
+ .Where(k => !KeyActionCatalog.IsKnownToken(k!.Value.Key)).Select(k => $"{a.Id}={k}")).ToList();
+ yield return (badTokens.Count == 0, badTokens.Count == 0 ? $"{os}: every default key uses a known token" : "unknown tokens: " + string.Join(", ", badTokens));
+
+ var kb = New(mac, new Settings());
+ var collisions = new SortedSet<string>(StringComparer.Ordinal);
+ foreach (var a in catalog)
+ foreach (var slot in new[] { KeySlot.Primary, KeySlot.Alternative })
+ if (a.Default(slot) is { } d)
+ foreach (var u in kb.FindConflicts(a.Id, slot, d, exemptDefaults: false))
+ collisions.Add(string.CompareOrdinal(a.Id, u.Action.Id) < 0 ? $"{a.Id}|{u.Action.Id}" : $"{u.Action.Id}|{a.Id}");
+ var unexpected = collisions.Where(c => !DefaultPairs.Contains(c)).ToList();
+ yield return (unexpected.Count == 0, unexpected.Count == 0 ? $"{os}: the shipped defaults collide only where intended ({string.Join(", ", collisions)})"
+ : $"{os}: default keys that collide: {string.Join(", ", unexpected)}");
+ var reserved = catalog.Where(a => !a.Fixed && a.DefaultPrimary is { } d && ReservedKeys.Reason(d, mac ? KeyPlatform.Mac : KeyPlatform.Windows) is not null)
+ .Select(a => a.Id).ToList();
+ yield return (reserved.Count == 0, reserved.Count == 0 ? $"{os}: no editable default sits on a system-reserved key" : "reserved defaults: " + string.Join(", ", reserved));
+ }
+
+ // ---- overrides round-trip, only changed slots stored -------------------------------
+ var settings = new Settings();
+ int saves = 0;
+ var b = New(true, settings, () => saves++);
+ var cmdT = new Shortcut(P, "T");
+ b.Set("edit.split", KeySlot.Primary, cmdT);
+ yield return (b.Matches("edit.split", cmdT) && !b.Matches("edit.split", new Shortcut(P, "E")) && b.IsEdited("edit.split") && saves == 1,
+ "rebinding Split to ⌘T: ⌘T splits, ⌘E doesn't, the row is edited, saved once");
+ yield return (settings.KeyBindings.Count == 1 && settings.KeyBindings["edit.split"].Primary == "⌘T" && settings.KeyBindings["edit.split"].Alternative is null,
+ "only the changed slot is stored (Primary \"⌘T\", Alternative left to the default)");
+ var reread = New(true, settings);
+ yield return (reread.Matches("edit.split", cmdT), "the custom key is read back from settings");
+ b.Set("edit.split", KeySlot.Primary, new Shortcut(P, "E"));
+ yield return (settings.KeyBindings.Count == 0 && !b.IsEdited("edit.split"), "setting the default again drops the entry and the edited mark");
+ b.Set("transport.metronome", KeySlot.Primary, null);
+ yield return (b.Current("transport.metronome") is null && settings.KeyBindings["transport.metronome"].Primary == "" && b.IsEdited("transport.metronome"),
+ "Clear leaves the action unassigned (\"\") and edited");
+
+ // ---- unreadable settings ----------------------------------------------------------
+ var junk = new Settings();
+ junk.KeyBindings["nope.gone"] = new KeyBindingOverride { Primary = "⌘K" };
+ junk.KeyBindings["edit.split"] = new KeyBindingOverride { Primary = "⌘@@" };
+ var warnings = new List<string>();
+ KeyBindings? jb = null;
+ try { jb = new KeyBindings(KeyActionCatalog.Create(true), junk, platform: KeyPlatform.Mac, warn: warnings.Add); } catch { }
+ yield return (jb is not null && jb.Matches("edit.split", new Shortcut(P, "E")) && warnings.Count == 2,
+ $"an unknown action and an unreadable key are skipped with a warning each ({warnings.Count}); Split keeps ⌘E");
+
+ // ---- damaged entries don't stop the app (review on nota#597) -----------------------
+ var nulls = new Settings();
+ nulls.KeyBindings["edit.split"] = null!;
+ KeyBindings? nb = null;
+ try { nb = new KeyBindings(KeyActionCatalog.Create(true), nulls, platform: KeyPlatform.Mac); } catch { }
+ var noDict = new Settings { KeyBindings = null! };
+ KeyBindings? db = null;
+ try { db = new KeyBindings(KeyActionCatalog.Create(true), noDict, platform: KeyPlatform.Mac); } catch { }
+ yield return (nb is not null && nb.Matches("edit.split", new Shortcut(P, "E")) && db is not null && noDict.KeyBindings is not null,
+ "a null entry and a null KeyBindings in settings load as defaults, no exception");
+
+ // ---- reserved and navigation keys -------------------------------------------------
+ yield return (b.Check("edit.split", new Shortcut(P, "Q")) == KeyCheck.Reserved, "⌘Q is refused on macOS");
+ var win = New(false, new Settings());
+ yield return (win.Check("edit.split", new Shortcut(A, "F4")) == KeyCheck.Reserved, "Alt+F4 is refused on Windows");
+ yield return (b.Check("session.rename", Shortcut.None("↑")) == KeyCheck.Navigation, "↑ is fixed for Session navigation");
+ yield return (b.Check("edit.split", new Shortcut(P, "K")) == KeyCheck.Ok, "⌘K is free to use");
+ yield return (b.Check("session.rename", new Shortcut(A, "↑")) == KeyCheck.Navigation
+ && b.Check("session.rename", new Shortcut(S, "←")) == KeyCheck.Navigation
+ && b.Check("session.rename", new Shortcut(P, "↑")) == KeyCheck.Ok,
+ "⌥↑ and ⇧← are the Session grid's navigation too; ⌘↑ is free there");
+
+ // ---- conflicts --------------------------------------------------------------------
+ var cmdD = new Shortcut(P, "D");
+ var c1 = b.FindConflicts("roll.transposeUp", KeySlot.Primary, cmdD);
+ yield return (c1.Any(u => u.Action.Id == "edit.duplicate"), "⌘D for Transpose up conflicts with Duplicate (a menu key reaches every scope)");
+ var shiftF = new Shortcut(S, "F");
+ var c2 = b.FindConflicts("arr.nudgeLeft", KeySlot.Primary, shiftF);
+ var s2 = b.FindShadows("arr.nudgeLeft", shiftF);
+ yield return (c2.Count == 0 && s2.Any(u => u.Action.Id == "roll.fitNotes"),
+ "⇧F for Nudge left is no conflict — the piano roll's Fit to notes is noted, it wins while it has focus");
+ var c3 = b.FindConflicts("edit.split", KeySlot.Primary, new Shortcut(P, "S"));
+ yield return (c3.Any(u => u.Action.Id == "file.save"), "⌘S for Split conflicts with Save (both window-wide)");
+ var c4 = b.FindConflicts("notes.c", KeySlot.Primary, Shortcut.None("P"));
+ yield return (c4.Any(u => u.Action.Id == "view.showPlayhead"), "P for a note conflicts with Show playhead (both window-wide)");
+ var c5 = b.FindConflicts("edit.delete", KeySlot.Alternative, Shortcut.None("⌫"));
+ yield return (c5.Any(u => u.Action.Id == "edit.delete" && u.Slot == KeySlot.Primary), "the same key in both slots of one action is flagged");
+
+ saves = 0;
+ b.Set("roll.transposeUp", KeySlot.Primary, cmdD, c1);
+ yield return (b.Matches("roll.transposeUp", cmdD) && b.Current("edit.duplicate") is null && b.IsEdited("edit.duplicate") && saves == 1,
+ "Replace moves ⌘D to Transpose up and leaves Duplicate unassigned — one change, saved once");
+ var rc = b.ResetConflicts("edit.duplicate");
+ yield return (rc.Any(u => u.Action.Id == "roll.transposeUp"), "resetting Duplicate first reports that ⌘D is now Transpose up");
+ b.Reset("edit.duplicate", rc);
+ yield return (b.Matches("edit.duplicate", cmdD) && !b.Matches("roll.transposeUp", cmdD), "Reset with Replace gives ⌘D back to Duplicate");
+ b.ResetAll();
+ yield return (!b.AnyEdited && settings.KeyBindings.Count == 0, "Reset all leaves nothing edited");
+
+ // ---- a new default on a user's key -------------------------------------------------
+ var upd = new Settings();
+ upd.KeyBindings["edit.split"] = new KeyBindingOverride { Primary = "⌘S" };
+ var ub = New(true, upd);
+ yield return (ub.Matches("edit.split", new Shortcut(P, "S")) && ub.Current("file.save") is null && ub.NeedsDecision.Contains("file.save"),
+ "a user key on a chord a default also uses: the user's key wins, the default rests under \"Needs a decision\"");
+
+ var alt = new Settings();
+ alt.KeyBindings["edit.split"] = new KeyBindingOverride { Primary = "⌦" };
+ var ab = New(true, alt);
+ yield return (ab.NeedsDecision.Contains("edit.delete") && ab.NeedsDecisionSlot("edit.delete") == KeySlot.Alternative
+ && ab.Matches("edit.delete", Shortcut.None("⌫")),
+ "a user key on Delete's alternative ⌦: the decision is about the alternative, ⌫ keeps working");
+
+ // ---- notes ------------------------------------------------------------------------
+ yield return (b.Matches("notes.c", Shortcut.None("A")) && b.Matches("notes.c2", Shortcut.None("K")) && b.Matches("notes.octaveUp", Shortcut.None("X")),
+ "the note map: A plays C, K the C above, X raises the octave");
+ }
+
+ /// <summary>The Shortcuts page's layout with the shipped (macOS) defaults, as JSON.</summary>
+ public static string Dump()
+ {
+ var actions = KeyActionCatalog.Create(mac: true);
+ var byId = actions.ToDictionary(a => a.Id);
+ var groups = ShortcutLayout.Build(actions, menuKey: true).Select(g => new
+ {
+ title = g.Title,
+ rows = g.Rows.Select(r => r.ActionId is { } id
+ ? new { keys = string.Join(" ", new[] { byId[id].DefaultPrimary, byId[id].DefaultAlternative }.Where(k => k is not null).Select(k => k!.Value.ToGlyphs())),
+ text = byId[id].Title, id = (string?)id, editable = !byId[id].Fixed }
+ : new { keys = r.Key, text = r.Text, id = (string?)null, editable = false }).ToList(),
+ });
+ return System.Text.Json.JsonSerializer.Serialize(new { groups }, new System.Text.Json.JsonSerializerOptions
+ {
+ WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ });
+ }
+
+ private static KeyBindings New(bool mac, Settings s, Action? save = null)
+ {
+ var kb = new KeyBindings(KeyActionCatalog.Create(mac), s, save, mac ? KeyPlatform.Mac : KeyPlatform.Windows);
+ kb.SetMenuCommands(MenuIds());
+ return kb;
+ }
+
+ private static List<string>? _menuIds;
+
+ // The commands MainWindow.axaml puts in the menu.
+ private static List<string> MenuIds()
+ {
+ if (_menuIds is not null) return _menuIds;
+ var dir = AppContext.BaseDirectory;
+ while (dir is not null && !File.Exists(Path.Combine(dir, "Nota.sln"))) dir = Path.GetDirectoryName(dir);
+ var axaml = dir is null ? "" : File.ReadAllText(Path.Combine(dir, "src/managed/Nota.App/MainWindow.axaml"));
+ return _menuIds = Regex.Matches(axaml, "app:Commands\\.Id=\"([^\"]+)\"").Select(m => m.Groups[1].Value).ToList();
+ }
+}
diff --git a/tests/Nota.SmokeTest/LocalizationAllowList.txt b/tests/Nota.SmokeTest/LocalizationAllowList.txt
index 76be8638..9bd08179 100644
--- a/tests/Nota.SmokeTest/LocalizationAllowList.txt
+++ b/tests/Nota.SmokeTest/LocalizationAllowList.txt
@@ -2733,4 +2733,27 @@ Nota.Application/Palette/CommandCatalog.cs preferences ai mcp claude assistant s
Nota.Application/Palette/CommandCatalog.cs preferences input device channels microphone names stereo pairs # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)
Nota.Application/Palette/CommandCatalog.cs preferences language langue francais english russian # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)
Nota.Application/Palette/CommandCatalog.cs preferences output device speakers headphones test tone # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)
-Nota.Application/Palette/CommandCatalog.cs preferences piano roll note names labels split fades detail panel # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)
\ No newline at end of file
+Nota.Application/Palette/CommandCatalog.cs preferences piano roll note names labels split fades detail panel # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)
+Nota.Application/Input/KeyActionCatalog.cs Arrangement # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs Session # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs computer keyboard note piano # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs computer keyboard octave # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs computer keyboard velocity # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs devices pattern clip tab detail # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs escape deselect stop gesture # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs menu bar # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs notes grid # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs off disable # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs parent folder # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs path type paste folder # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs play launch slot scene # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs semitone pitch # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs zoom all nodes # data: search keywords and view ids of the key actions, not shown (specs/096)
+Nota.Application/Input/KeyActionCatalog.cs Return # data: a key token (the key's own name), not a sentence
+Nota.Application/Input/ShortcutLayout.cs Return # data: a key token (the key's own name), not a sentence
+Nota.App/PreferencesWindow.Shortcuts.cs Return # data: a key token (the key's own name), not a sentence
+Nota.Application/Input/ReservedKeys.cs Linux # data: operating-system names (proper nouns)
+Nota.Application/Input/ReservedKeys.cs Windows # data: operating-system names (proper nouns)
+Nota.Application/Input/KeyBindings.cs $"Nota shortcuts: ignoring unknown action '{id}'" # data: log text for the support log, not shown
+Nota.Application/Input/KeyBindings.cs $"Nota shortcuts: ignoring unreadable key '{t}' for '{id}'" # data: log text for the support log, not shown
+Nota.Application/Input/KeyBindings.cs $"Nota shortcuts: ignoring an empty entry for '{id}'" # data: log text for the support log, not shown
diff --git a/tests/Nota.SmokeTest/Nota.SmokeTest.csproj b/tests/Nota.SmokeTest/Nota.SmokeTest.csproj
index 162fc100..a23d2862 100644
--- a/tests/Nota.SmokeTest/Nota.SmokeTest.csproj
+++ b/tests/Nota.SmokeTest/Nota.SmokeTest.csproj
@@ -43,6 +43,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="12.1.4" />
<Compile Include="..\..\src\managed\Nota.App\Input\ShortcutAvaloniaExtensions.cs" Link="ShortcutAvaloniaExtensions.cs" />
+ <Compile Include="..\..\src\managed\Nota.App\Input\KeyTokens.cs" Link="KeyTokens.cs" />
<!-- The Menu key's copy of the application menu (specs/093; Avalonia base only). -->
<Compile Include="..\..\src\managed\Nota.App\MenuMirror.cs" Link="MenuMirror.cs" />
<!-- What's New's changelog / release-notes parsers (no Avalonia inside). -->
diff --git a/tests/Nota.SmokeTest/PaletteTests.cs b/tests/Nota.SmokeTest/PaletteTests.cs
index 472f8f62..9cdb6e57 100644
--- a/tests/Nota.SmokeTest/PaletteTests.cs
+++ b/tests/Nota.SmokeTest/PaletteTests.cs
@@ -320,7 +320,7 @@ internal static class PaletteTests
}
// Source checks: the menu names only catalog commands, every command has a handler, and
- // every shortcut the catalog declares is listed in Settings → Shortcuts.
+ // every key action is listed in Settings → Shortcuts.
private static IEnumerable<(bool, string)> RegistryDrift()
{
var dir = AppContext.BaseDirectory;
@@ -355,14 +355,16 @@ internal static class PaletteTests
? $"every Settings page ({pageIds.Count}) has its palette command and every command its page"
: $"Settings pages and commands disagree: {string.Join(", ", badPages)}");
- var listed = System.Text.RegularExpressions.Regex.Matches(prefs, "\\(\"([^\"]+)\",\\s*(?:Loc\\.T\\()?\"").Select(m => m.Groups[1].Value)
- .SelectMany(k => k.Split(' ', StringSplitOptions.RemoveEmptyEntries)).Select(Canon).ToHashSet();
- var missing = catalog.Where(c => c.Gesture.Length > 0 && !listed.Contains(Canon(c.Gesture))).Select(c => $"{c.Gesture} ({c.Title})").ToList();
- yield return (missing.Count == 0, missing.Count == 0 ? "every catalog shortcut is listed in Settings → Shortcuts"
- : $"shortcuts missing from Settings → Shortcuts: {string.Join(", ", missing)}");
-
- // Modifier order doesn't matter: ⌥⌘S and ⌘⌥S are the same key.
- static string Canon(string k) => new string(k.Where(c => "⌘⌃⌥⇧".Contains(c)).OrderBy(c => c).ToArray()) + new string(k.Where(c => !"⌘⌃⌥⇧".Contains(c)).ToArray());
+ // Settings → Shortcuts lists every key action exactly once (specs/096): its layout is
+ // built from the key-action catalog, which takes in every command of this catalog.
+ var actions = Nota.Application.Input.KeyActionCatalog.Create();
+ var laid = Nota.Application.Input.ShortcutLayout.Build(actions, menuKey: true)
+ .SelectMany(g => g.Rows).Where(r => r.ActionId is not null).Select(r => r.ActionId!).ToList();
+ var notLaid = actions.Select(x => x.Id).Where(id => !laid.Contains(id)).ToList();
+ var twice = laid.GroupBy(x => x).Where(g => g.Count() > 1).Select(g => g.Key).ToList();
+ yield return (notLaid.Count == 0 && twice.Count == 0, notLaid.Count == 0 && twice.Count == 0
+ ? $"every key action ({actions.Count}) is listed once in Settings → Shortcuts"
+ : $"Settings → Shortcuts misses {string.Join(", ", notLaid)} · lists twice {string.Join(", ", twice)}");
}
private static IEnumerable<(bool, string)> Performance()
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 06708b18..b4696d35 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -198,11 +198,28 @@ if (args.Length >= 1 && args[0] == "--menu-mirror")
Console.WriteLine(failures == 0 ? "MENU MIRROR PASSED" : $"MENU MIRROR FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
+// The Shortcuts page as JSON for the user manual (nota-docs `npm run shortcuts`, specs/096):
+// `--shortcuts-dump <file> [language.json]` — groups, rows, the default keys in macOS glyphs,
+// editable or fixed; with a language file, its texts (English where it lacks one).
+if (args.Length >= 2 && args[0] == "--shortcuts-dump")
+{
+ if (args.Length >= 3)
+ {
+ var table = Nota.Application.Localization.TranslationTable.Parse(File.ReadAllText(args[2]), out var langError);
+ if (table is null) { Console.Error.WriteLine($"{args[2]}: {langError}"); return 1; }
+ Nota.Application.Localization.Loc.Install(table, table.Code);
+ }
+ File.WriteAllText(args[1], KeyBindingTests.Dump());
+ Console.WriteLine($"wrote {args[1]}");
+ return 0;
+}
// Shortcut builder alone: `--shortcuts`.
if (args.Length >= 1 && args[0] == "--shortcuts")
{
Console.WriteLine("-- shortcut builder --");
foreach (var (ok, label) in ShortcutBuilderTests.Run()) Check(ok, label);
+ Console.WriteLine("-- custom shortcuts --");
+ foreach (var (ok, label) in KeyBindingTests.Run()) Check(ok, label);
Console.WriteLine(failures == 0 ? "SHORTCUTS PASSED" : $"SHORTCUTS FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
@@ -15974,6 +15991,10 @@ foreach (var (ok, label) in FilterGlideTests.Run()) Check(ok, label);
Console.WriteLine("-- shortcut builder --");
foreach (var (ok, label) in ShortcutBuilderTests.Run()) Check(ok, label);
+// --- custom keyboard shortcuts: catalog, conflicts, overrides, reset (specs/096) ---
+Console.WriteLine("-- custom shortcuts --");
+foreach (var (ok, label) in KeyBindingTests.Run()) Check(ok, label);
+
// --- command palette: descriptors, golden queries, context table, undo, speed ---
Console.WriteLine("-- command palette --");
foreach (var (ok, label) in PaletteTests.Run()) Check(ok, label);