Skip to content

Commit 962a6f6

Browse files
committed
Trema is the more robust method for capital umlauts
1 parent c3087ab commit 962a6f6

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

ui/src/components/popovers/PasteModal.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,44 @@ export default function PasteModal() {
4848

4949
try {
5050
for (const char of text) {
51-
const { key, shift, altRight, space, capsLock } = chars[keyboardLayout][char] ?? {};
51+
const { key, shift, altRight, space, capsLock, trema } = chars[keyboardLayout][char] ?? {};
5252
if (!key) continue;
5353

54-
const keyz = [keys[key]];
54+
const keyz = [ keys[key] ];
55+
const modz = [ shift ? modifiers["ShiftLeft"] : 0
56+
| (altRight ? modifiers["AltRight"] : 0) ];
57+
5558
if (space) {
5659
keyz.push(keys["Space"]);
60+
modz.push(0);
5761
}
5862
if (capsLock) {
5963
keyz.unshift(keys["CapsLock"]);
64+
modz.unshift(0);
65+
6066
keyz.push(keys["CapsLock"]);
67+
modz.push(0);
68+
}
69+
if (trema) {
70+
keyz.unshift(keys["BracketRight"]); // trema ¨
71+
modz.unshift(0)
6172
}
6273

63-
const modz = shift ? modifiers["ShiftLeft"] : 0
64-
| (altRight ? modifiers["AltRight"] : 0);
65-
66-
await new Promise<void>((resolve, reject) => {
67-
send(
68-
"keyboardReport",
69-
hidKeyboardPayload(keyz, modz),
70-
params => {
71-
if ("error" in params) return reject(params.error);
72-
send("keyboardReport", hidKeyboardPayload([], 0), params => {
74+
for (const [index, keyy] of keyz.entries()) {
75+
await new Promise<void>((resolve, reject) => {
76+
send(
77+
"keyboardReport",
78+
hidKeyboardPayload([keyy], modz[index]),
79+
params => {
7380
if ("error" in params) return reject(params.error);
74-
resolve();
75-
});
76-
},
77-
);
78-
});
81+
send("keyboardReport", hidKeyboardPayload([], 0), params => {
82+
if ("error" in params) return reject(params.error);
83+
resolve();
84+
});
85+
},
86+
);
87+
});
88+
}
7989
}
8090
} catch (error) {
8191
console.error(error);

ui/src/keyboardLayouts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export const layouts = {
99
export const chars = {
1010
"en_US": chars_en_US,
1111
"de_CH": chars_de_CH,
12-
} as Record<string, Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean }>>;
12+
} as Record<string, Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean, trema?: boolean }>>;

ui/src/keyboardLayouts/de_CH.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const chars = {
22
A: { key: "KeyA", shift: true },
3+
"Ä": { key: "KeyA", shift: true, trema: true },
34
B: { key: "KeyB", shift: true },
45
C: { key: "KeyC", shift: true },
56
D: { key: "KeyD", shift: true },
@@ -14,12 +15,14 @@ export const chars = {
1415
M: { key: "KeyM", shift: true },
1516
N: { key: "KeyN", shift: true },
1617
O: { key: "KeyO", shift: true },
18+
"Ö": { key: "KeyO", shift: true, trema: true },
1719
P: { key: "KeyP", shift: true },
1820
Q: { key: "KeyQ", shift: true },
1921
R: { key: "KeyR", shift: true },
2022
S: { key: "KeyS", shift: true },
2123
T: { key: "KeyT", shift: true },
2224
U: { key: "KeyU", shift: true },
25+
"Ü": { key: "KeyU", shift: true, trema: true },
2326
V: { key: "KeyV", shift: true },
2427
W: { key: "KeyW", shift: true },
2528
X: { key: "KeyX", shift: true },
@@ -108,16 +111,13 @@ export const chars = {
108111
"ü": { key: "BracketLeft" },
109112
"è": { key: "BracketLeft", shift: true },
110113
"[": { key: "BracketLeft", altRight: true },
111-
"Ü": { key: "BracketLeft", capsLock: true },
112114
"!": { key: "BracketRight", shift: true },
113115
"]": { key: "BracketRight", altRight: true },
114116
"ö": { key: "Semicolon" },
115117
"é": { key: "Semicolon", shift: true },
116-
"Ö": { key: "Semicolon", capsLock: true },
117118
"ä": { key: "Quote" },
118119
"à": { key: "Quote", shift: true },
119120
"{": { key: "Quote", altRight: true },
120-
"Ä": { key: "Quote", capsLock: true },
121121
"$": { key: "Backslash" },
122122
"£": { key: "Backslash", shift: true },
123123
"}": { key: "Backslash", altRight: true },
@@ -137,4 +137,4 @@ export const chars = {
137137
"\n": { key: "Enter" },
138138
Enter: { key: "Enter" },
139139
Tab: { key: "Tab" },
140-
} as Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean }>
140+
} as Record<string, { key: string | number; shift?: boolean, altRight?: boolean, space?: boolean, capsLock?: boolean, trema?: boolean }>

0 commit comments

Comments
 (0)