mirror of https://github.com/jetkvm/kvm.git
Trema is the more robust method for capital umlauts
This commit is contained in:
parent
c3087abe02
commit
962a6f6dfc
|
@ -48,34 +48,44 @@ export default function PasteModal() {
|
|||
|
||||
try {
|
||||
for (const char of text) {
|
||||
const { key, shift, altRight, space, capsLock } = chars[keyboardLayout][char] ?? {};
|
||||
const { key, shift, altRight, space, capsLock, trema } = chars[keyboardLayout][char] ?? {};
|
||||
if (!key) continue;
|
||||
|
||||
const keyz = [keys[key]];
|
||||
const keyz = [ keys[key] ];
|
||||
const modz = [ shift ? modifiers["ShiftLeft"] : 0
|
||||
| (altRight ? modifiers["AltRight"] : 0) ];
|
||||
|
||||
if (space) {
|
||||
keyz.push(keys["Space"]);
|
||||
modz.push(0);
|
||||
}
|
||||
if (capsLock) {
|
||||
keyz.unshift(keys["CapsLock"]);
|
||||
modz.unshift(0);
|
||||
|
||||
keyz.push(keys["CapsLock"]);
|
||||
modz.push(0);
|
||||
}
|
||||
if (trema) {
|
||||
keyz.unshift(keys["BracketRight"]); // trema ¨
|
||||
modz.unshift(0)
|
||||
}
|
||||
|
||||
const modz = shift ? modifiers["ShiftLeft"] : 0
|
||||
| (altRight ? modifiers["AltRight"] : 0);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
send(
|
||||
"keyboardReport",
|
||||
hidKeyboardPayload(keyz, modz),
|
||||
params => {
|
||||
if ("error" in params) return reject(params.error);
|
||||
send("keyboardReport", hidKeyboardPayload([], 0), params => {
|
||||
for (const [index, keyy] of keyz.entries()) {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
send(
|
||||
"keyboardReport",
|
||||
hidKeyboardPayload([keyy], modz[index]),
|
||||
params => {
|
||||
if ("error" in params) return reject(params.error);
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
send("keyboardReport", hidKeyboardPayload([], 0), params => {
|
||||
if ("error" in params) return reject(params.error);
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
|
|
@ -9,4 +9,4 @@ export const layouts = {
|
|||
export const chars = {
|
||||
"en_US": chars_en_US,
|
||||
"de_CH": chars_de_CH,
|
||||
} as Record<string, Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean }>>;
|
||||
} as Record<string, Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean, trema?: boolean }>>;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export const chars = {
|
||||
A: { key: "KeyA", shift: true },
|
||||
"Ä": { key: "KeyA", shift: true, trema: true },
|
||||
B: { key: "KeyB", shift: true },
|
||||
C: { key: "KeyC", shift: true },
|
||||
D: { key: "KeyD", shift: true },
|
||||
|
@ -14,12 +15,14 @@ export const chars = {
|
|||
M: { key: "KeyM", shift: true },
|
||||
N: { key: "KeyN", shift: true },
|
||||
O: { key: "KeyO", shift: true },
|
||||
"Ö": { key: "KeyO", shift: true, trema: true },
|
||||
P: { key: "KeyP", shift: true },
|
||||
Q: { key: "KeyQ", shift: true },
|
||||
R: { key: "KeyR", shift: true },
|
||||
S: { key: "KeyS", shift: true },
|
||||
T: { key: "KeyT", shift: true },
|
||||
U: { key: "KeyU", shift: true },
|
||||
"Ü": { key: "KeyU", shift: true, trema: true },
|
||||
V: { key: "KeyV", shift: true },
|
||||
W: { key: "KeyW", shift: true },
|
||||
X: { key: "KeyX", shift: true },
|
||||
|
@ -108,16 +111,13 @@ export const chars = {
|
|||
"ü": { key: "BracketLeft" },
|
||||
"è": { key: "BracketLeft", shift: true },
|
||||
"[": { key: "BracketLeft", altRight: true },
|
||||
"Ü": { key: "BracketLeft", capsLock: true },
|
||||
"!": { key: "BracketRight", shift: true },
|
||||
"]": { key: "BracketRight", altRight: true },
|
||||
"ö": { key: "Semicolon" },
|
||||
"é": { key: "Semicolon", shift: true },
|
||||
"Ö": { key: "Semicolon", capsLock: true },
|
||||
"ä": { key: "Quote" },
|
||||
"à": { key: "Quote", shift: true },
|
||||
"{": { key: "Quote", altRight: true },
|
||||
"Ä": { key: "Quote", capsLock: true },
|
||||
"$": { key: "Backslash" },
|
||||
"£": { key: "Backslash", shift: true },
|
||||
"}": { key: "Backslash", altRight: true },
|
||||
|
@ -137,4 +137,4 @@ export const chars = {
|
|||
"\n": { key: "Enter" },
|
||||
Enter: { key: "Enter" },
|
||||
Tab: { key: "Tab" },
|
||||
} as Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean }>
|
||||
} as Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean, trema?: boolean }>
|
||||
|
|
Loading…
Reference in New Issue