Keyboard shortcut overlay

This commit is contained in:
Ian Gulliver
2026-10-16 08:39:17 -07:00
parent 2624324b48
commit 14cf1f582b
9 changed files with 143 additions and 9 deletions
+47
View File
@@ -27,8 +27,55 @@ export function bindShortcuts() {
void confirmMerge(state.selectedTaskId);
}
}
else if (e.key === "/") {
e.preventDefault();
showShortcuts();
}
});
}
const shortcuts = [
[
"Anywhere",
[
["⌘K", "Switch task, or create one"],
["⌘P", "Open the Project tab"],
["⌘L", "Open the Lead tab and its composer"],
["⌘S", "Merge the right pane's task"],
["⌘/", "Show these shortcuts"],
["Esc", "Close the switcher or a dialog"],
],
],
[
"Task switcher",
[
["↑ ↓", "Move the highlight"],
["Enter", "Pick the highlighted row"],
],
],
[
"Composer and inbox answers",
[
["Enter", "Send"],
["Shift+Enter", "New line"],
["Enter / Space", "Pick the focused choice"],
],
],
[
"Dialogs",
[["Enter", "Confirm"]],
],
[
"Terminal",
[["Ctrl+…", "Goes to the shell, not to byre"]],
],
];
function showShortcuts() {
void showAlert([
h("h2", { class: "shortcuts-title" }, "Keyboard shortcuts"),
...shortcuts.map(([group, rows]) => h("section", { class: "shortcuts-group" }, h("h3", {}, group), h("dl", {}, ...rows.flatMap(([keys, what]) => [h("dt", {}, h("kbd", {}, keys)), h("dd", {}, what)])))),
h("p", { class: "hint" }, "Ctrl works in place of ⌘."),
]);
}
export function openSwitcher() {
if (document.querySelector(".switcher")) {
return;