diff --git a/ui/src/components/popovers/PasteModal.tsx b/ui/src/components/popovers/PasteModal.tsx index 9e3d9ee..543af00 100644 --- a/ui/src/components/popovers/PasteModal.tsx +++ b/ui/src/components/popovers/PasteModal.tsx @@ -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((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((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); diff --git a/ui/src/keyboardLayouts.ts b/ui/src/keyboardLayouts.ts index 15c3be4..a995e3d 100644 --- a/ui/src/keyboardLayouts.ts +++ b/ui/src/keyboardLayouts.ts @@ -9,4 +9,4 @@ export const layouts = { export const chars = { "en_US": chars_en_US, "de_CH": chars_de_CH, -} as Record>; +} as Record>; diff --git a/ui/src/keyboardLayouts/de_CH.ts b/ui/src/keyboardLayouts/de_CH.ts index 405feb8..893ebe4 100644 --- a/ui/src/keyboardLayouts/de_CH.ts +++ b/ui/src/keyboardLayouts/de_CH.ts @@ -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 +} as Record