fix: standardize control key naming across platforms, fixed #3860

- Updated the control key naming in the SpecialKeys object for Windows, macOS, and Linux to ensure consistency.
- Modified the transformShortcut function to replace "$mod" with "Control" instead of "Ctrl" for better clarity.
- Adjusted the key sorting order to reflect the updated naming convention.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-06-04 20:20:45 +08:00
parent e5e474b987
commit 9dd5109bf8
2 changed files with 5 additions and 2 deletions
@@ -23,6 +23,7 @@ const SpecialKeys = {
Windows: {
meta: "⊞",
ctrl: "Ctrl",
control: "Ctrl",
alt: "Alt",
shift: "Shift",
escape: "Esc",
@@ -30,6 +31,7 @@ const SpecialKeys = {
macOS: {
meta: "⌘",
ctrl: "⌃",
control: "⌃",
alt: "⌥",
shift: "⇧",
escape: "⎋",
@@ -37,6 +39,7 @@ const SpecialKeys = {
Linux: {
meta: "Super",
ctrl: "Ctrl",
control: "Ctrl",
alt: "Alt",
shift: "Shift",
escape: "Escape",
+2 -2
View File
@@ -350,13 +350,13 @@ export function transformShortcut(shortcut: string, platform: OS = getOS()): str
if (platform === "macOS") {
return shortcut.replace("$mod", "Meta")
}
return shortcut.replace("$mod", "Ctrl")
return shortcut.replace("$mod", "Control")
}
const F_KEY_REGEX = /^F(?:[1-9]|1[0-2])$/
function getKeySortValue(key: string): number {
const order = ["Shift", "Ctrl", "Meta", "Alt"]
const order = ["Shift", "Control", "Meta", "Alt"]
if (order.includes(key)) {
return order.indexOf(key)