Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit f317248

Browse files
committed
✨ List available shortcuts with Ctrl+Shift+K
1 parent f453c9f commit f317248

File tree

4 files changed

+91
-7
lines changed

4 files changed

+91
-7
lines changed

src/_renderer.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,62 @@ window.writeSettingsFile = () => {
772772
document.getElementById("settingsEditorStatus").innerText = "New values written to settings.json file at "+new Date().toTimeString();
773773
};
774774

775+
// Display available keyboard shortcuts
776+
window.openShortcutsHelp = () => {
777+
new Modal({
778+
type: "custom",
779+
title: `Available Keyboard Shortcuts <i>(v${electron.remote.app.getVersion()})</i>`,
780+
html: `<h5>Using either the on-screen or a physical keyboard, you can use the following shortcuts:</h5>
781+
<table id="shortcutsHelp" style="width: 100%;">
782+
<tr>
783+
<th>Trigger</th>
784+
<th>Action</th>
785+
</tr>
786+
<tr>
787+
<td>${process.platform === "darwin" ? "Command" : "Ctrl + Shift"} + C</td>
788+
<td>Copy selected buffer from the terminal.</td>
789+
</tr>
790+
<tr>
791+
<td>${process.platform === "darwin" ? "Command" : "Ctrl + Shift"} + V</td>
792+
<td>Paste system clipboard to the terminal.</td>
793+
</tr>
794+
<tr>
795+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Tab</td>
796+
<td>Switch to the next opened terminal tab (left to right order).</td>
797+
</tr>
798+
<tr>
799+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Shift + Tab</td>
800+
<td>Switch to the previous opened terminal tab (right to left order).</td>
801+
</tr>
802+
<tr>
803+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + [1-5]</td>
804+
<td>Switch to a specific terminal tab, or create it if it hasn't been opened yet.</td>
805+
</tr>
806+
<tr>
807+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Shift + S</td>
808+
<td>Open the settings editor.</td>
809+
</tr>
810+
<tr>
811+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Shift + K</td>
812+
<td>List available keyboard shortcuts.</td>
813+
</tr>
814+
<tr>
815+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Shift + H</td>
816+
<td>Toggle hidden files and directories in the file browser.</td>
817+
</tr>
818+
<tr>
819+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Shift + P</td>
820+
<td>Toggle the on-screen keyboard's "Password Mode", that allows you to safely type<br> sensitive information even if your screen might be recorded (disables visual input feedback).</td>
821+
</tr>
822+
<tr>
823+
<td>${process.platform === "darwin" ? "Command" : "Ctrl"} + Shift + I</td>
824+
<td>Open Chromium Dev Tools (for debugging purposes).</td>
825+
</tr>
826+
</table>
827+
<br>`
828+
});
829+
};
830+
775831
// Global keyboard shortcuts
776832
const globalShortcut = electron.remote.globalShortcut;
777833
globalShortcut.unregisterAll();
@@ -789,6 +845,13 @@ function registerKeyboardShortcuts() {
789845
}
790846
});
791847

848+
// Open list of keyboard shortcuts
849+
globalShortcut.register("CommandOrControl+Shift+K", () => {
850+
if (!document.getElementById("shortcutsHelp")) {
851+
window.openShortcutsHelp();
852+
}
853+
});
854+
792855
// Copy and paste shortcuts
793856

794857
if (process.platform === "darwin") {

src/assets/css/modal.css

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,34 @@ div.modal_popup button {
8484
}
8585

8686
div.modal_popup button:hover {
87-
background: rgba(var(--color_r), var(--color_g), var(--color_b), 0.5)
87+
background: rgba(var(--color_r), var(--color_g), var(--color_b), 0.5);
8888
}
8989

90-
/* Settings editor modal */
91-
table#settingsEditor, table#settingsEditor th, table#settingsEditor td {
90+
div.modal_popup table, div.modal_popup table th, div.modal_popup table td {
9291
border: 0.15vh solid rgb(var(--color_r), var(--color_g), var(--color_b));
9392
border-collapse: collapse;
9493
}
9594

96-
table#settingsEditor th, table#settingsEditor td {
95+
div.modal_popup table th, div.modal_popup table td {
9796
padding: 0.3vh;
9897
}
9998

100-
table#settingsEditor th {
99+
div.modal_popup table th {
101100
font-size: 2vh;
101+
background: rgba(var(--color_r), var(--color_g), var(--color_b), 0.6);
102+
color: var(--color_light_black);
102103
}
103104

104-
table#settingsEditor td {
105+
div.modal_popup table td {
105106
font-size: 1.7vh;
106107
}
107108

109+
div.modal_popup table:not(#settingsEditor) td:first-child {
110+
text-align: center;
111+
}
112+
113+
/* Settings editor modal */
114+
108115
table#settingsEditor td input {
109116
width: 100%;
110117
background: var(--color_light_black);
@@ -137,3 +144,11 @@ h6#settingsEditorStatus {
137144
font-size: 1.5vh;
138145
font-style: italic;
139146
}
147+
148+
/* Keyboard shortcuts modal */
149+
150+
table#shortcutsHelp td:first-child {
151+
word-spacing: .3vh;
152+
font-weight: bold;
153+
padding: .8vh;
154+
}

src/classes/keyboard.class.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ class Keyboard {
313313

314314
// Keyboard shortcuts
315315
if (this.container.dataset.isCtrlOn === "true" && this.container.dataset.isShiftOn === "true") {
316+
console.log(key.dataset);
316317
switch(cmd) {
317318
case "c":
318319
window.term[window.currentTerm].clipboard.copy();
@@ -325,6 +326,11 @@ class Keyboard {
325326
window.openSettings();
326327
}
327328
return true;
329+
case "k":
330+
if (!document.getElementById("shortcutsHelp")) {
331+
window.openShortcutsHelp();
332+
}
333+
return true;
328334
case "i":
329335
electron.remote.getCurrentWindow().webContents.toggleDevTools();
330336
return true;

src/classes/modal.class.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Modal {
3030
case "custom":
3131
classes += " info custom";
3232
zindex = 500;
33-
buttons = options.buttons;
33+
buttons = options.buttons || [];
3434
buttons.push({label:"Close", action:"window.modals["+this.id+"].close();"});
3535
break;
3636
default:

0 commit comments

Comments
 (0)