From bec34f2d57da26f35fdfcc8c2d112deea5b55927 Mon Sep 17 00:00:00 2001 From: Gurkiran Singh <61521805+g4rry420@users.noreply.github.com> Date: Wed, 12 May 2021 04:57:35 -0400 Subject: [PATCH] feat: Shortcut key for nerd stats (#3552) * added alt+/ as the shortcut key for nerd stats Signed-off-by: gurkiran_singh * added shortcut info in HelpDialog.ts Signed-off-by: gurkiran_singh * resolved conflicts Signed-off-by: gurkiran_singh * added shortcut info in HelpDialog.ts Signed-off-by: gurkiran_singh --- src/actions/actionToggleStats.tsx | 3 +++ src/actions/shortcuts.ts | 2 +- src/components/HelpDialog.tsx | 4 ++++ src/keys.ts | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/actions/actionToggleStats.tsx b/src/actions/actionToggleStats.tsx index 3c03b80c..68236093 100644 --- a/src/actions/actionToggleStats.tsx +++ b/src/actions/actionToggleStats.tsx @@ -1,4 +1,5 @@ import { register } from "./register"; +import { CODES, KEYS } from "../keys"; export const actionToggleStats = register({ name: "stats", @@ -13,4 +14,6 @@ export const actionToggleStats = register({ }, checked: (appState) => appState.showStats, contextItemLabel: "stats.title", + keyTest: (event) => + !event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.SLASH, }); diff --git a/src/actions/shortcuts.ts b/src/actions/shortcuts.ts index 23df3791..0f0880f7 100644 --- a/src/actions/shortcuts.ts +++ b/src/actions/shortcuts.ts @@ -57,7 +57,7 @@ const shortcutMap: Record = { ungroup: [getShortcutKey("CtrlOrCmd+Shift+G")], gridMode: [getShortcutKey("CtrlOrCmd+'")], zenMode: [getShortcutKey("Alt+Z")], - stats: [], + stats: [getShortcutKey("Alt+/")], addToLibrary: [], flipHorizontal: [getShortcutKey("Shift+H")], flipVertical: [getShortcutKey("Shift+V")], diff --git a/src/components/HelpDialog.tsx b/src/components/HelpDialog.tsx index 17191d18..f985c596 100644 --- a/src/components/HelpDialog.tsx +++ b/src/components/HelpDialog.tsx @@ -235,6 +235,10 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => { label={t("labels.toggleTheme")} shortcuts={[getShortcutKey("Alt+Shift+D")]} /> + diff --git a/src/keys.ts b/src/keys.ts index 5ac2d894..a2f188f7 100644 --- a/src/keys.ts +++ b/src/keys.ts @@ -14,6 +14,7 @@ export const CODES = { NINE: "Digit9", QUOTE: "Quote", ZERO: "Digit0", + SLASH: "Slash", C: "KeyC", D: "KeyD", G: "KeyG",