Skip to content

Commit

Permalink
Add additional keyboard shortcuts (#1839)
Browse files Browse the repository at this point in the history
Resolves #1838.
Related #481.

This change adds the following additional keyboard shortcuts:

- Ctrl+Alt+Backspace - Restart the desktop environment on Linux.
- Meta+Alt+Escape - Open the "Force Quit" utility on macOS.
- Alt+Tab - Switch to the next window on macOS, Windows, and more.

I've mimicked the approach of sending one key at a time used by the
existing Ctrl+Alt+Delete shortcut to more accurately represent how a
user would enter these shortcuts on a physical keyboard.
<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1839"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
  • Loading branch information
cghague authored Aug 16, 2024
1 parent d8b7589 commit 0d5b783
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
50 changes: 50 additions & 0 deletions app/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,56 @@ menuBar.addEventListener("ctrl-alt-del-requested", () => {
code: "Delete",
});
});
menuBar.addEventListener("ctrl-alt-backspace-requested", () => {
processKeystroke({
ctrlLeft: true,
key: "Control",
code: "ControlLeft",
});
processKeystroke({
ctrlLeft: true,
altLeft: true,
key: "Alt",
code: "AltLeft",
});
processKeystroke({
ctrlLeft: true,
altLeft: true,
key: "Backspace",
code: "Backspace",
});
});
menuBar.addEventListener("meta-alt-escape-requested", () => {
processKeystroke({
metaLeft: true,
key: "Meta",
code: "MetaLeft",
});
processKeystroke({
metaLeft: true,
altLeft: true,
key: "Alt",
code: "AltLeft",
});
processKeystroke({
metaLeft: true,
altLeft: true,
key: "Esc",
code: "Escape",
});
});
menuBar.addEventListener("alt-tab-requested", () => {
processKeystroke({
altLeft: true,
key: "Alt",
code: "AltLeft",
});
processKeystroke({
altLeft: true,
key: "Tab",
code: "Tab",
});
});

setKeystrokeHistoryStatus(settings.isKeystrokeHistoryEnabled());

Expand Down
19 changes: 18 additions & 1 deletion app/templates/custom-elements/menu-bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,24 @@
<ul class="items" role="group">
<li class="item" role="presentation">
<a data-onclick-event="ctrl-alt-del-requested" role="menuitem"
>Ctrl + Alt + Del</a
>Ctrl + Alt + Delete</a
>
</li>
<li class="item" role="presentation">
<a
data-onclick-event="ctrl-alt-backspace-requested"
role="menuitem"
>Ctrl + Alt + Backspace</a
>
</li>
<li class="item" role="presentation">
<a data-onclick-event="meta-alt-escape-requested" role="menuitem"
>Meta + Alt + Escape</a
>
</li>
<li class="item" role="presentation">
<a data-onclick-event="alt-tab-requested" role="menuitem"
>Alt + Tab</a
>
</li>
</ul>
Expand Down

0 comments on commit 0d5b783

Please sign in to comment.