fix: check hotkey and optimize hotkey input, close #287

This commit is contained in:
GyDi
2022-11-23 17:30:19 +08:00
parent 6bc83d9f27
commit db028665fd
6 changed files with 74 additions and 18 deletions

View File

@@ -1,4 +1,26 @@
const parseHotkey = (key: string) => {
const KEY_MAP: Record<string, string> = {
'"': "'",
":": ";",
"?": "/",
">": ".",
"<": ",",
"{": "[",
"}": "]",
"|": "\\",
"!": "1",
"@": "2",
"#": "3",
$: "4",
"%": "5",
"^": "6",
"&": "7",
"*": "8",
"(": "9",
")": "0",
"~": "`",
};
export const parseHotkey = (key: string) => {
let temp = key.toUpperCase();
if (temp.startsWith("ARROW")) {
@@ -20,10 +42,7 @@ const parseHotkey = (key: string) => {
return "CMD";
case " ":
return "SPACE";
default:
return temp;
return KEY_MAP[temp] || temp;
}
};
export default parseHotkey;