feat: hotkey viewer
This commit is contained in:
29
src/utils/parse-hotkey.ts
Normal file
29
src/utils/parse-hotkey.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
const parseHotkey = (key: string) => {
|
||||
let temp = key.toUpperCase();
|
||||
|
||||
if (temp.startsWith("ARROW")) {
|
||||
temp = temp.slice(5);
|
||||
} else if (temp.startsWith("DIGIT")) {
|
||||
temp = temp.slice(5);
|
||||
} else if (temp.startsWith("KEY")) {
|
||||
temp = temp.slice(3);
|
||||
} else if (temp.endsWith("LEFT")) {
|
||||
temp = temp.slice(0, -4);
|
||||
} else if (temp.endsWith("RIGHT")) {
|
||||
temp = temp.slice(0, -5);
|
||||
}
|
||||
|
||||
switch (temp) {
|
||||
case "CONTROL":
|
||||
return "CTRL";
|
||||
case "META":
|
||||
return "CMD";
|
||||
case " ":
|
||||
return "SPACE";
|
||||
|
||||
default:
|
||||
return temp;
|
||||
}
|
||||
};
|
||||
|
||||
export default parseHotkey;
|
||||
Reference in New Issue
Block a user