This commit is contained in:
Vanessa 2022-06-18 20:11:20 +08:00
parent 84eb6c90e0
commit e18e9c2750
3 changed files with 12 additions and 5 deletions

View File

@ -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 += ".";

View File

@ -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: "⌥←"},

View File

@ -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);
}
}
});
}