summaryrefslogtreecommitdiff
path: root/apps/web/src/types
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-07-18 11:37:48 +0200
committerMaze Winther <mazewinther@gmail.com>2025-07-18 11:37:48 +0200
commit74e7d427aaed3517ce578c2192f783dacffc02fc (patch)
treec6ec27070940778e64ca3ad50cd937227f87f3ac /apps/web/src/types
parentc4e6a9a45ab0f0afdde4f0c9991e39cd5d6205d0 (diff)
parent23001f8442e60999e34c0d6c348fecf0867b6cad (diff)
downloadopencut-74e7d427aaed3517ce578c2192f783dacffc02fc.tar.gz
Merge branch 'feat/shortcut-actions' into staging
Diffstat (limited to 'apps/web/src/types')
-rw-r--r--apps/web/src/types/keybinding.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/apps/web/src/types/keybinding.ts b/apps/web/src/types/keybinding.ts
new file mode 100644
index 00000000..d97c88da
--- /dev/null
+++ b/apps/web/src/types/keybinding.ts
@@ -0,0 +1,35 @@
+import { ActionWithOptionalArgs } from "@/constants/actions";
+
+/**
+ * Alt is also regarded as macOS OPTION (⌥) key
+ * Ctrl is also regarded as macOS COMMAND (⌘) key (NOTE: this differs from HTML Keyboard spec where COMMAND is Meta key!)
+ */
+export type ModifierKeys =
+ | "ctrl"
+ | "alt"
+ | "shift"
+ | "ctrl+shift"
+ | "alt+shift"
+ | "ctrl+alt"
+ | "ctrl+alt+shift";
+
+/* eslint-disable prettier/prettier */
+// prettier-ignore
+export type Key =
+ | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j"
+ | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t"
+ | "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" | "2" | "3"
+ | "4" | "5" | "6" | "7" | "8" | "9" | "up" | "down" | "left"
+ | "right" | "/" | "?" | "." | "enter" | "tab" | "space"
+ | "escape" | "esc" | "backspace" | "delete" | "home" | "end"
+/* eslint-enable */
+
+export type ModifierBasedShortcutKey = `${ModifierKeys}+${Key}`;
+// Singular keybindings (these will be disabled when an input-ish area has been focused)
+export type SingleCharacterShortcutKey = `${Key}`;
+
+export type ShortcutKey = ModifierBasedShortcutKey | SingleCharacterShortcutKey;
+
+export type KeybindingConfig = {
+ [key in ShortcutKey]?: ActionWithOptionalArgs;
+};