From b4c970f4bab8df217abe7223041e6426dab980e3 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 27 Apr 2024 15:39:00 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/11165 --- app/src/protyle/util/hotKey.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/util/hotKey.ts b/app/src/protyle/util/hotKey.ts index e4bccf090..692cdaf6f 100644 --- a/app/src/protyle/util/hotKey.ts +++ b/app/src/protyle/util/hotKey.ts @@ -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"); } // 是否匹配 ⇧[]