Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/5230

Vanessae18e9c27507e
diff --git a/app/src/config/keymap.ts b/app/src/config/keymap.ts
index d50f99da6a..3e4084787a 100644
--- a/app/src/config/keymap.ts
+++ b/app/src/config/keymap.ts
@@ -231,7 +231,7 @@ export const keymap = {
keymapStr += "⌦";
} else if (event.altKey) {
const codeKey = event.code.substr(event.code.length - 1, 1).toUpperCase();
- if (event.key === "Enter") {
+ if (event.key === "Enter" || (event.key.startsWith("F") && event.key.length > 1)) {
keymapStr += event.key;
} else if (event.code === "Period") {
keymapStr += ".";
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 05d313d2c1..b6d9dfa2ab 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -82,7 +82,7 @@ export abstract class Constants {
};
// "⌘", "⇧", "⌥", "⌃"
- // "⌘S", "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧Enter", "Enter", "PageUp", "PageDown", "⌫", "⌦", "F9" 不可自定义
+ // "⌘S", "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "F9" 不可自定义
public static readonly SIYUAN_KEYMAP: IKeymap = {
general: {
enterBack: {default: "⌥←", custom: "⌥←"},
diff --git a/app/src/protyle/util/hotKey.ts b/app/src/protyle/util/hotKey.ts
index d9fdc82c7d..fcd5d7e20d 100644
--- a/app/src/protyle/util/hotKey.ts
+++ b/app/src/protyle/util/hotKey.ts
@@ -18,8 +18,9 @@ export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
return false;
}
- const hotKeys = hotKey.replace("Enter", Constants.ZWSP).split("");
- if (hotKey.endsWith("↑") || hotKey.endsWith("↓") || hotKey.endsWith("→") || hotKey.endsWith("←") || hotKey.endsWith("Enter") || hotKey.endsWith("⇥")) {
+ const hotKeys = hotKey.split("");
+ if (hotKey.endsWith("↑") || hotKey.endsWith("↓") || hotKey.endsWith("→") || hotKey.endsWith("←") ||
+ hotKey.endsWith("↩") || hotKey.endsWith("⇥") || hotKey.indexOf("F") > -1) {
hotKeys.forEach((item, index) => {
if (item === "↑") {
hotKeys[index] = "ArrowUp";
@@ -31,8 +32,14 @@ export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
hotKeys[index] = "ArrowRight";
} else if (item === "⇥") {
hotKeys[index] = "Tab";
- } else if (item === Constants.ZWSP) {
+ } else if (item === "↩") {
hotKeys[index] = "Enter";
+ } else if (item === "F") {
+ // F1-F12
+ hotKeys[index] = "F" + hotKeys.splice(index + 1, 1);
+ if (hotKeys[index + 1]) {
+ hotKeys[index + 1] += hotKeys.splice(index + 1, 1);
+ }
}
});
}