mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
fix: modifier keys on windows and linux (#922)
This commit is contained in:
parent
538d4be8be
commit
3f7af7bfb8
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1 +1 @@
|
|||||||
* text=lf
|
* text eol=lf
|
@ -314,9 +314,9 @@ const TerminalView = ({ blockId, model }: TerminalViewProps) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PLATFORM == "win32" || PLATFORM == "linux") {
|
if (PLATFORM == "win32" || PLATFORM == "linux") {
|
||||||
const reservedAltKeys = ["Alt:t", "Alt:n", "Alt:w", "Alt:m", "Alt:g", "Alt:[", "Alt:]", "Alt:Shift:r"];
|
const reservedCmdKeys = ["Cmd:t", "Cmd:n", "Cmd:w", "Cmd:m", "Cmd:g", "Cmd:[", "Cmd:]", "Cmd:Shift:r"];
|
||||||
for (let i = 0; i < reservedAltKeys.length; i++) {
|
for (let i = 0; i < reservedCmdKeys.length; i++) {
|
||||||
if (keyutil.checkKeyPressed(waveEvent, reservedAltKeys[i])) {
|
if (keyutil.checkKeyPressed(waveEvent, reservedCmdKeys[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,16 +47,36 @@ function parseKeyDescription(keyDescription: string): KeyPressDecl {
|
|||||||
let keys = keyDescription.replace(/[()]/g, "").split(":");
|
let keys = keyDescription.replace(/[()]/g, "").split(":");
|
||||||
for (let key of keys) {
|
for (let key of keys) {
|
||||||
if (key == "Cmd") {
|
if (key == "Cmd") {
|
||||||
|
if (PLATFORM == PlatformMacOS) {
|
||||||
|
rtn.mods.Meta = true;
|
||||||
|
} else {
|
||||||
|
rtn.mods.Alt = true;
|
||||||
|
}
|
||||||
rtn.mods.Cmd = true;
|
rtn.mods.Cmd = true;
|
||||||
} else if (key == "Shift") {
|
} else if (key == "Shift") {
|
||||||
rtn.mods.Shift = true;
|
rtn.mods.Shift = true;
|
||||||
} else if (key == "Ctrl") {
|
} else if (key == "Ctrl") {
|
||||||
rtn.mods.Ctrl = true;
|
rtn.mods.Ctrl = true;
|
||||||
} else if (key == "Option") {
|
} else if (key == "Option") {
|
||||||
|
if (PLATFORM == PlatformMacOS) {
|
||||||
|
rtn.mods.Alt = true;
|
||||||
|
} else {
|
||||||
|
rtn.mods.Meta = true;
|
||||||
|
}
|
||||||
rtn.mods.Option = true;
|
rtn.mods.Option = true;
|
||||||
} else if (key == "Alt") {
|
} else if (key == "Alt") {
|
||||||
|
if (PLATFORM == PlatformMacOS) {
|
||||||
|
rtn.mods.Option = true;
|
||||||
|
} else {
|
||||||
|
rtn.mods.Cmd = true;
|
||||||
|
}
|
||||||
rtn.mods.Alt = true;
|
rtn.mods.Alt = true;
|
||||||
} else if (key == "Meta") {
|
} else if (key == "Meta") {
|
||||||
|
if (PLATFORM == PlatformMacOS) {
|
||||||
|
rtn.mods.Cmd = true;
|
||||||
|
} else {
|
||||||
|
rtn.mods.Option = true;
|
||||||
|
}
|
||||||
rtn.mods.Meta = true;
|
rtn.mods.Meta = true;
|
||||||
} else {
|
} else {
|
||||||
let { key: parsedKey, type: keyType } = parseKey(key);
|
let { key: parsedKey, type: keyType } = parseKey(key);
|
||||||
@ -138,10 +158,10 @@ function isInputEvent(event: WaveKeyboardEvent): boolean {
|
|||||||
|
|
||||||
function checkKeyPressed(event: WaveKeyboardEvent, keyDescription: string): boolean {
|
function checkKeyPressed(event: WaveKeyboardEvent, keyDescription: string): boolean {
|
||||||
let keyPress = parseKeyDescription(keyDescription);
|
let keyPress = parseKeyDescription(keyDescription);
|
||||||
if (!keyPress.mods.Alt && notMod(keyPress.mods.Option, event.option)) {
|
if (notMod(keyPress.mods.Option, event.option)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!keyPress.mods.Meta && notMod(keyPress.mods.Cmd, event.cmd)) {
|
if (notMod(keyPress.mods.Cmd, event.cmd)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (notMod(keyPress.mods.Shift, event.shift)) {
|
if (notMod(keyPress.mods.Shift, event.shift)) {
|
||||||
@ -150,10 +170,10 @@ function checkKeyPressed(event: WaveKeyboardEvent, keyDescription: string): bool
|
|||||||
if (notMod(keyPress.mods.Ctrl, event.control)) {
|
if (notMod(keyPress.mods.Ctrl, event.control)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (keyPress.mods.Alt && !event.alt) {
|
if (notMod(keyPress.mods.Alt, event.alt)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (keyPress.mods.Meta && !event.meta) {
|
if (notMod(keyPress.mods.Meta, event.meta)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let eventKey = "";
|
let eventKey = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user