Vanessa 2024-04-27 15:39:00 +08:00
parent 03a6c15d70
commit b4c970f4ba

View file

@ -42,6 +42,16 @@ export const matchAuxiliaryHotKey = (hotKey: string, event: KeyboardEvent) => {
return true;
};
const replaceDirect = (hotKey: string, keyCode: string) => {
const hotKeys = hotKey.replace(keyCode, Constants.ZWSP).split("");
hotKeys.forEach((item, index) => {
if (item === Constants.ZWSP) {
hotKeys[index] = keyCode;
}
})
return hotKeys;
}
export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
if (!hotKey) {
return false;
@ -67,7 +77,7 @@ export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
return false;
}
const hotKeys = hotKey.split("");
let hotKeys = hotKey.split("");
if (hotKey.indexOf("F") > -1) {
hotKeys.forEach((item, index) => {
if (item === "F") {
@ -78,6 +88,14 @@ export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
}
}
});
} else if (hotKey.indexOf("PageUp") > -1) {
hotKeys = replaceDirect(hotKey, "PageUp");
} else if (hotKey.indexOf("PageDown") > -1) {
hotKeys = replaceDirect(hotKey, "PageDown");
} else if (hotKey.indexOf("Home") > -1) {
hotKeys = replaceDirect(hotKey, "Home");
} else if (hotKey.indexOf("End") > -1) {
hotKeys = replaceDirect(hotKey, "End");
}
// 是否匹配 ⇧[]