diff --git a/docs/src/api/params.md b/docs/src/api/params.md index c14ce631d105ec..d1d56dc9d34c80 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -1741,9 +1741,17 @@ Keyboard layout code. Currently, the following values are supported: | Values | Name | | :- | :- | -| `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | -| `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | -| `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | -| `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | -| `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | -| `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | +| `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | +| `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | +| `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | +| `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | +| `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | +| `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | +| `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | +| `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | +| `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | +| `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | +| `es`, `es-ES`, `ca-ES` | [Spanish & Catalan (Spain)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | +| `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | +| `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | +| `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | diff --git a/packages/playwright-core/src/server/chromium/crInput.ts b/packages/playwright-core/src/server/chromium/crInput.ts index bbfd973d10f97f..ff69640d64232c 100644 --- a/packages/playwright-core/src/server/chromium/crInput.ts +++ b/packages/playwright-core/src/server/chromium/crInput.ts @@ -54,6 +54,8 @@ export class RawKeyboardImpl implements input.RawKeyboard { if (code === 'Escape' && await this._dragManger.cancelDrag()) return; const commands = this._commandsForCode(code, modifiers); + if (key === 'Dead') + text = ''; await this._client.send('Input.dispatchKeyEvent', { type: text ? 'keyDown' : 'rawKeyDown', modifiers: toModifiersMask(modifiers), diff --git a/packages/playwright-core/src/server/firefox/ffInput.ts b/packages/playwright-core/src/server/firefox/ffInput.ts index e69ab54633c914..664449c39fc6bd 100644 --- a/packages/playwright-core/src/server/firefox/ffInput.ts +++ b/packages/playwright-core/src/server/firefox/ffInput.ts @@ -69,6 +69,8 @@ export class RawKeyboardImpl implements input.RawKeyboard { // Firefox will figure out Enter by itself if (text === '\r') text = ''; + if (key === 'Dead') + text = ''; await this._client.send('Page.dispatchKeyEvent', { type: 'keydown', keyCode: keyCodeWithoutLocation, diff --git a/packages/playwright-core/src/server/input.ts b/packages/playwright-core/src/server/input.ts index e68f5bd96539d0..5470cab7028722 100644 --- a/packages/playwright-core/src/server/input.ts +++ b/packages/playwright-core/src/server/input.ts @@ -30,8 +30,13 @@ type KeyDescription = { code: string, location: number, shifted?: KeyDescription; + deadKeyMappings?: Map; }; +// either the key description or a sequence of keys for accented keys +// e.g. in portuguese, 'à' will be ['Shift+BracketRight', 'a'] +type KeyboardLayoutClosure = Map; + const kModifiers: types.KeyboardModifier[] = ['Alt', 'Control', 'Meta', 'Shift']; export interface RawKeyboard { @@ -45,7 +50,8 @@ export class Keyboard { private _pressedKeys = new Set(); private _raw: RawKeyboard; private _page: Page; - private _keyboardLayout: Map; + private _keyboardLayout: Map; + private _deadKeyMappings?: Map; constructor(raw: RawKeyboard, page: Page) { this._raw = raw; @@ -59,24 +65,33 @@ export class Keyboard { async down(key: string) { const description = this._keyDescriptionForString(key); + this._deadKeyMappings = undefined; const autoRepeat = this._pressedKeys.has(description.code); this._pressedKeys.add(description.code); if (kModifiers.includes(description.key as types.KeyboardModifier)) this._pressedModifiers.add(description.key as types.KeyboardModifier); - const text = description.text; - await this._raw.keydown(this._pressedModifiers, description.code, description.keyCode, description.keyCodeWithoutLocation, description.key, description.location, autoRepeat, text); + const descKey = description.deadKeyMappings ? 'Dead' : description.key; + await this._raw.keydown(this._pressedModifiers, description.code, description.keyCode, description.keyCodeWithoutLocation, descKey, description.location, autoRepeat, description.text); } private _keyDescriptionForString(keyString: string): KeyDescription { let description = this._keyboardLayout.get(keyString); assert(description, `Unknown key: "${keyString}"`); + assert(!Array.isArray(description), `Accented key not supported: "${keyString}"`); + const shift = this._pressedModifiers.has('Shift'); description = shift && description.shifted ? description.shifted : description; // if any modifiers besides shift are pressed, no text should be sent if (this._pressedModifiers.size > 1 || (!this._pressedModifiers.has('Shift') && this._pressedModifiers.size === 1)) return { ...description, text: '' }; - return description; + + if (!this._deadKeyMappings) return description; + + // handle deadkeys / accented keys + const deadKeyText = this._deadKeyMappings.get(description.text) ?? this._deadKeyMappings.get(''); + assert(deadKeyText, `Unknown key: "${description.text}"`); + return { ...description, text: deadKeyText, key: deadKeyText }; } async up(key: string) { @@ -84,7 +99,9 @@ export class Keyboard { if (kModifiers.includes(description.key as types.KeyboardModifier)) this._pressedModifiers.delete(description.key as types.KeyboardModifier); this._pressedKeys.delete(description.code); - await this._raw.keyup(this._pressedModifiers, description.code, description.keyCode, description.keyCodeWithoutLocation, description.key, description.location); + const descKey = description.deadKeyMappings ? 'Dead' : description.key; + await this._raw.keyup(this._pressedModifiers, description.code, description.keyCode, description.keyCodeWithoutLocation, descKey, description.location); + if (description.key !== 'Shift') this._deadKeyMappings = description.deadKeyMappings; } async insertText(text: string) { @@ -94,8 +111,14 @@ export class Keyboard { async type(text: string, options?: { delay?: number }) { const delay = (options && options.delay) || undefined; for (const char of text) { - if (this._keyboardLayout.has(char)) { - await this.press(char, { delay }); + const descOrKeySequence = this._keyboardLayout.get(char); + if (descOrKeySequence) { + if (Array.isArray(descOrKeySequence)) { + for (const key of descOrKeySequence) + await this.press(key, { delay }); + } else { + await this.press(char, { delay }); + } } else { if (delay) await new Promise(f => setTimeout(f, delay)); @@ -249,17 +272,17 @@ const aliases = new Map([ ]); const defaultKeyboard = _buildLayoutClosure(defaultKeyboardLayout); -const cache = new Map>( +const cache = new Map( // initialized with the default keyboard layout [[defaultKlid, defaultKeyboard]] ); -function getByLocale(locale?: string): Map { +function getByLocale(locale?: string): KeyboardLayoutClosure { if (!locale) return defaultKeyboard; const normalizedLocale = normalizeLocale(locale); const klid = localeMapping.get(normalizedLocale); - if (!klid) throw new Error(`Keyboard layout name '${klid}' not found`); + if (!klid) throw new Error(`Keyboard layout name "${locale}" not found`); const cached = cache.get(klid); if (cached) return cached; @@ -277,8 +300,8 @@ function normalizeLocale(locale: string) { return locale.replace(/-/g, '_').toLowerCase(); } -function _buildLayoutClosure(layout: KeyboardLayout): Map { - const result = new Map(); +function _buildLayoutClosure(layout: KeyboardLayout): KeyboardLayoutClosure { + const result = new Map(); for (const code in layout) { const definition = layout[code]; const description: KeyDescription = { @@ -288,6 +311,7 @@ function _buildLayoutClosure(layout: KeyboardLayout): Map { ... descrption, shifted } @@ -320,9 +346,24 @@ function _buildLayoutClosure(layout: KeyboardLayout): Map([ - ['us', '00000409'], // US keyboard - ['en_us', '00000409'], // US keyboard - ['es', '0000040A'], // Spanish keyboard - ['es_es', '0000040A'], // Spanish keyboard - ['br', '00000416'], // Portuguese (Brazil ABNT) keyboard - ['pt_br', '00000416'], // Portuguese (Brazil ABNT) keyboard - ['latam', '0000080A'], // Latin American keyboard - ['es_mx', '0000080A'], // Latin American keyboard - ['pt', '00000816'], // Portuguese keyboard - ['pt_pt', '00000816'], // Portuguese keyboard - ['el', '00000408'], // Greek keyboard - ['el_gr', '00000408'], // Greek keyboard + ['us', '00000409'], // US English + ['en_us', '00000409'], // US English + ['gb', '00000809'], // British + ['en_gb', '00000809'], // British + ['dk', '00000406'], // Danish + ['da_dk', '00000406'], // Danish + ['fr', '0000040C'], // French + ['fr_fr', '0000040C'], // French + ['de', '00000407'], // German + ['de_de', '00000407'], // German + ['it', '00000410'], // Italian + ['it_it', '00000410'], // Italian + ['pt', '00000816'], // Portuguese (Portugal) + ['pt_pt', '00000816'], // Portuguese (Portugal) + ['br', '00000416'], // Portuguese (Brazil) + ['pt_br', '00000416'], // Portuguese (Brazil) + ['ru', '00000419'], // Russian + ['ru_ru', '00000419'], // Russian + ['ua', '00020422'], // Ukrainian + ['uk_ua', '00020422'], // Ukrainian + ['es', '0000040A'], // Spanish & Catalan (Spain) + ['es_es', '0000040A'], // Spanish & Catalan (Spain) + ['ca_es', '0000040A'], // Spanish & Catalan (Spain) + ['latam', '0000080A'], // Spanish (Latin America) + ['ch', '00000807'], // German (Switzerland) + ['de_ch', '00000807'], // German (Switzerland) + ['fr_ch', '0000100C'], // French and Italian (Switzerland) + ['it_ch', '0000100C'], // French and Italian (Switzerland) ]); export const keypadLocation = 3; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000406.ts b/packages/playwright-core/src/server/keyboards/layouts/00000406.ts new file mode 100644 index 00000000000000..760bdb56eabda2 --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00000406.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00000406 - Danish +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '½', keyCode: 220, shiftKey: '§' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '!' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '#' }, + Digit4: { key: '4', keyCode: 52, shiftKey: '¤' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '&' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '/' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '(' }, + Digit9: { key: '9', keyCode: 57, shiftKey: ')' }, + Digit0: { key: '0', keyCode: 48, shiftKey: '=' }, + Minus: { key: '+', keyCode: 187, shiftKey: '?' }, + Equal: { key: '´', keyCode: 219, shiftKey: '`', deadKeyMappings: { 'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú', 'y': 'ý', 'A': 'Á', 'E': 'É', 'I': 'Í', 'O': 'Ó', 'U': 'Ú', 'Y': 'Ý', ' ': '´' }, shiftDeadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' } }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyW: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: 'å', keyCode: 221, shiftKey: 'Å' }, + BracketRight: { key: '¨', keyCode: 186, shiftKey: '^', deadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '¨' }, shiftDeadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' } }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: 'æ', keyCode: 192, shiftKey: 'Æ' }, + Quote: { key: 'ø', keyCode: 222, shiftKey: 'Ø' }, + Backslash: { key: '\'', keyCode: 191, shiftKey: '*' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, + KeyZ: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Comma: { key: ',', keyCode: 188, shiftKey: ';' }, + Period: { key: '.', keyCode: 190, shiftKey: ':' }, + Slash: { key: '-', keyCode: 189, shiftKey: '_' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000407.ts b/packages/playwright-core/src/server/keyboards/layouts/00000407.ts new file mode 100644 index 00000000000000..b4d4d1fa0309a0 --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00000407.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00000407 - German +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '^', keyCode: 220, shiftKey: '°', deadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' } }, + Digit1: { key: '1', keyCode: 49, shiftKey: '!' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '§' }, + Digit4: { key: '4', keyCode: 52, shiftKey: '$' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '&' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '/' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '(' }, + Digit9: { key: '9', keyCode: 57, shiftKey: ')' }, + Digit0: { key: '0', keyCode: 48, shiftKey: '=' }, + Minus: { key: 'ß', keyCode: 219, shiftKey: '?' }, + Equal: { key: '´', keyCode: 221, shiftKey: '`', deadKeyMappings: { 'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú', 'y': 'ý', 'A': 'Á', 'E': 'É', 'I': 'Í', 'O': 'Ó', 'U': 'Ú', 'Y': 'Ý', ' ': '´' }, shiftDeadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' } }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyW: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: 'ü', keyCode: 186, shiftKey: 'Ü' }, + BracketRight: { key: '+', keyCode: 187, shiftKey: '*' }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: 'ö', keyCode: 192, shiftKey: 'Ö' }, + Quote: { key: 'ä', keyCode: 222, shiftKey: 'Ä' }, + Backslash: { key: '#', keyCode: 191, shiftKey: '\'' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, + KeyZ: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Comma: { key: ',', keyCode: 188, shiftKey: ';' }, + Period: { key: '.', keyCode: 190, shiftKey: ':' }, + Slash: { key: '-', keyCode: 189, shiftKey: '_' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000409.ts b/packages/playwright-core/src/server/keyboards/layouts/00000409.ts index 1bbe1a5756061b..4df2c180aab8dc 100644 --- a/packages/playwright-core/src/server/keyboards/layouts/00000409.ts +++ b/packages/playwright-core/src/server/keyboards/layouts/00000409.ts @@ -18,7 +18,7 @@ import type { KeyboardLayout } from '../types'; -// KLID 00000409 - US keyboard +// KLID 00000409 - US English const keyboardLayout: KeyboardLayout = { Escape: { key: 'Escape', keyCode: 27 }, F1: { key: 'F1', keyCode: 112 }, diff --git a/packages/playwright-core/src/server/keyboards/layouts/0000040A.ts b/packages/playwright-core/src/server/keyboards/layouts/0000040A.ts index 864ce21f982e3e..3ef507e076aae1 100644 --- a/packages/playwright-core/src/server/keyboards/layouts/0000040A.ts +++ b/packages/playwright-core/src/server/keyboards/layouts/0000040A.ts @@ -18,7 +18,7 @@ import type { KeyboardLayout } from '../types'; -// KLID 0000040A - Spanish keyboard +// KLID 0000040A - Spanish & Catalan (Spain) const keyboardLayout: KeyboardLayout = { Escape: { key: 'Escape', keyCode: 27 }, F1: { key: 'F1', keyCode: 112 }, @@ -58,7 +58,7 @@ const keyboardLayout: KeyboardLayout = { KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, - BracketLeft: { key: '`', keyCode: 186, shiftKey: '^' }, + BracketLeft: { key: '`', keyCode: 186, shiftKey: '^', deadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' }, shiftDeadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' } }, BracketRight: { key: '+', keyCode: 187, shiftKey: '*' }, Enter: { key: 'Enter', keyCode: 13, text: '\r' }, CapsLock: { key: 'CapsLock', keyCode: 20 }, @@ -72,7 +72,7 @@ const keyboardLayout: KeyboardLayout = { KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, Semicolon: { key: 'ñ', keyCode: 192, shiftKey: 'Ñ' }, - Quote: { key: '´', keyCode: 222, shiftKey: '¨' }, + Quote: { key: '´', keyCode: 222, shiftKey: '¨', deadKeyMappings: { 'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú', 'y': 'ý', 'A': 'Á', 'E': 'É', 'I': 'Í', 'O': 'Ó', 'U': 'Ú', 'Y': 'Ý', ' ': '´' }, shiftDeadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '¨' } }, Backslash: { key: 'ç', keyCode: 191, shiftKey: 'Ç' }, ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, diff --git a/packages/playwright-core/src/server/keyboards/layouts/0000040C.ts b/packages/playwright-core/src/server/keyboards/layouts/0000040C.ts new file mode 100644 index 00000000000000..2d0fb5d4da825c --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/0000040C.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 0000040C - French +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '²', keyCode: 222 }, + Digit1: { key: '&', keyCode: 49, shiftKey: '1' }, + Digit2: { key: 'é', keyCode: 50, shiftKey: '2' }, + Digit3: { key: '"', keyCode: 51, shiftKey: '3' }, + Digit4: { key: '\'', keyCode: 52, shiftKey: '4' }, + Digit5: { key: '(', keyCode: 53, shiftKey: '5' }, + Digit6: { key: '-', keyCode: 54, shiftKey: '6' }, + Digit7: { key: 'è', keyCode: 55, shiftKey: '7' }, + Digit8: { key: '_', keyCode: 56, shiftKey: '8' }, + Digit9: { key: 'ç', keyCode: 57, shiftKey: '9' }, + Digit0: { key: 'à', keyCode: 48, shiftKey: '0' }, + Minus: { key: ')', keyCode: 219, shiftKey: '°' }, + Equal: { key: '=', keyCode: 187, shiftKey: '+' }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyW: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: '^', keyCode: 221, shiftKey: '¨', deadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' }, shiftDeadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '¨' } }, + BracketRight: { key: '$', keyCode: 186, shiftKey: '£' }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Quote: { key: 'ù', keyCode: 192, shiftKey: '%' }, + Backslash: { key: '*', keyCode: 220, shiftKey: 'µ' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, + KeyZ: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: ',', keyCode: 188, shiftKey: '?' }, + Comma: { key: ';', keyCode: 190, shiftKey: '.' }, + Period: { key: ':', keyCode: 191, shiftKey: '/' }, + Slash: { key: '!', keyCode: 223, shiftKey: '§' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000410.ts b/packages/playwright-core/src/server/keyboards/layouts/00000410.ts new file mode 100644 index 00000000000000..4f5cdc8d72977a --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00000410.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00000410 - Italian +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '\\', keyCode: 220, shiftKey: '|' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '!' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '£' }, + Digit4: { key: '4', keyCode: 52, shiftKey: '$' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '&' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '/' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '(' }, + Digit9: { key: '9', keyCode: 57, shiftKey: ')' }, + Digit0: { key: '0', keyCode: 48, shiftKey: '=' }, + Minus: { key: '\'', keyCode: 219, shiftKey: '?' }, + Equal: { key: 'ì', keyCode: 221, shiftKey: '^' }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyW: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: 'è', keyCode: 186, shiftKey: 'é' }, + BracketRight: { key: '+', keyCode: 187, shiftKey: '*' }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: 'ò', keyCode: 192, shiftKey: 'ç' }, + Quote: { key: 'à', keyCode: 222, shiftKey: '°' }, + Backslash: { key: 'ù', keyCode: 191, shiftKey: '§' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, + KeyZ: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Comma: { key: ',', keyCode: 188, shiftKey: ';' }, + Period: { key: '.', keyCode: 190, shiftKey: ':' }, + Slash: { key: '-', keyCode: 189, shiftKey: '_' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000416.ts b/packages/playwright-core/src/server/keyboards/layouts/00000416.ts index 3d21172dc90703..57ba8996db889e 100644 --- a/packages/playwright-core/src/server/keyboards/layouts/00000416.ts +++ b/packages/playwright-core/src/server/keyboards/layouts/00000416.ts @@ -18,7 +18,7 @@ import type { KeyboardLayout } from '../types'; -// KLID 00000416 - Portuguese (Brazil ABNT) keyboard +// KLID 00000416 - Portuguese (Brazil) const keyboardLayout: KeyboardLayout = { Escape: { key: 'Escape', keyCode: 27 }, F1: { key: 'F1', keyCode: 112 }, @@ -39,7 +39,7 @@ const keyboardLayout: KeyboardLayout = { Digit3: { key: '3', keyCode: 51, shiftKey: '#' }, Digit4: { key: '4', keyCode: 52, shiftKey: '$' }, Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, - Digit6: { key: '6', keyCode: 54, shiftKey: '¨' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '¨', shiftDeadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '¨' } }, Digit7: { key: '7', keyCode: 55, shiftKey: '&' }, Digit8: { key: '8', keyCode: 56, shiftKey: '*' }, Digit9: { key: '9', keyCode: 57, shiftKey: '(' }, @@ -58,7 +58,7 @@ const keyboardLayout: KeyboardLayout = { KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, - BracketLeft: { key: '´', keyCode: 219, shiftKey: '`' }, + BracketLeft: { key: '´', keyCode: 219, shiftKey: '`', deadKeyMappings: { 'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú', 'y': 'ý', 'A': 'Á', 'E': 'É', 'I': 'Í', 'O': 'Ó', 'U': 'Ú', 'Y': 'Ý', ' ': '´' }, shiftDeadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' } }, BracketRight: { key: '[', keyCode: 221, shiftKey: '{' }, Enter: { key: 'Enter', keyCode: 13, text: '\r' }, CapsLock: { key: 'CapsLock', keyCode: 20 }, @@ -72,7 +72,7 @@ const keyboardLayout: KeyboardLayout = { KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, Semicolon: { key: 'ç', keyCode: 186, shiftKey: 'Ç' }, - Quote: { key: '~', keyCode: 222, shiftKey: '^' }, + Quote: { key: '~', keyCode: 222, shiftKey: '^', deadKeyMappings: { 'a': 'ã', 'o': 'õ', 'n': 'ñ', 'A': 'Ã', 'O': 'Õ', 'N': 'Ñ', ' ': '~' }, shiftDeadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' } }, Backslash: { key: ']', keyCode: 220, shiftKey: '}' }, ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, IntlBackslash: { key: '\\', keyCode: 226, shiftKey: '|' }, diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000419.ts b/packages/playwright-core/src/server/keyboards/layouts/00000419.ts new file mode 100644 index 00000000000000..8cffc08781fffb --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00000419.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00000419 - Russian +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: 'ё', keyCode: 192, shiftKey: 'Ё' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '!' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '№' }, + Digit4: { key: '4', keyCode: 52, shiftKey: ';' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: ':' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '?' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '*' }, + Digit9: { key: '9', keyCode: 57, shiftKey: '(' }, + Digit0: { key: '0', keyCode: 48, shiftKey: ')' }, + Minus: { key: '-', keyCode: 189, shiftKey: '_' }, + Equal: { key: '=', keyCode: 187, shiftKey: '+' }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'й', keyCode: 81, shiftKey: 'Й' }, + KeyW: { key: 'ц', keyCode: 87, shiftKey: 'Ц' }, + KeyE: { key: 'у', keyCode: 69, shiftKey: 'У' }, + KeyR: { key: 'к', keyCode: 82, shiftKey: 'К' }, + KeyT: { key: 'е', keyCode: 84, shiftKey: 'Е' }, + KeyY: { key: 'н', keyCode: 89, shiftKey: 'Н' }, + KeyU: { key: 'г', keyCode: 85, shiftKey: 'Г' }, + KeyI: { key: 'ш', keyCode: 73, shiftKey: 'Ш' }, + KeyO: { key: 'щ', keyCode: 79, shiftKey: 'Щ' }, + KeyP: { key: 'з', keyCode: 80, shiftKey: 'З' }, + BracketLeft: { key: 'х', keyCode: 219, shiftKey: 'Х' }, + BracketRight: { key: 'ъ', keyCode: 221, shiftKey: 'Ъ' }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'ф', keyCode: 65, shiftKey: 'Ф' }, + KeyS: { key: 'ы', keyCode: 83, shiftKey: 'Ы' }, + KeyD: { key: 'в', keyCode: 68, shiftKey: 'В' }, + KeyF: { key: 'а', keyCode: 70, shiftKey: 'А' }, + KeyG: { key: 'п', keyCode: 71, shiftKey: 'П' }, + KeyH: { key: 'р', keyCode: 72, shiftKey: 'Р' }, + KeyJ: { key: 'о', keyCode: 74, shiftKey: 'О' }, + KeyK: { key: 'л', keyCode: 75, shiftKey: 'Л' }, + KeyL: { key: 'д', keyCode: 76, shiftKey: 'Д' }, + Semicolon: { key: 'ж', keyCode: 186, shiftKey: 'Ж' }, + Quote: { key: 'э', keyCode: 222, shiftKey: 'Э' }, + Backslash: { key: '\\', keyCode: 220, shiftKey: '/' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '\\', keyCode: 226, shiftKey: '/' }, + KeyZ: { key: 'я', keyCode: 90, shiftKey: 'Я' }, + KeyX: { key: 'ч', keyCode: 88, shiftKey: 'Ч' }, + KeyC: { key: 'с', keyCode: 67, shiftKey: 'С' }, + KeyV: { key: 'м', keyCode: 86, shiftKey: 'М' }, + KeyB: { key: 'и', keyCode: 66, shiftKey: 'И' }, + KeyN: { key: 'т', keyCode: 78, shiftKey: 'Т' }, + KeyM: { key: 'ь', keyCode: 77, shiftKey: 'Ь' }, + Comma: { key: 'б', keyCode: 188, shiftKey: 'Б' }, + Period: { key: 'ю', keyCode: 190, shiftKey: 'Ю' }, + Slash: { key: '.', keyCode: 191, shiftKey: ',' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000807.ts b/packages/playwright-core/src/server/keyboards/layouts/00000807.ts new file mode 100644 index 00000000000000..bcee9568a2f288 --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00000807.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00000807 - German (Switzerland) +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '§', keyCode: 191, shiftKey: '°' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '+' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '*' }, + Digit4: { key: '4', keyCode: 52, shiftKey: 'ç' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '&' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '/' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '(' }, + Digit9: { key: '9', keyCode: 57, shiftKey: ')' }, + Digit0: { key: '0', keyCode: 48, shiftKey: '=' }, + Minus: { key: '\'', keyCode: 219, shiftKey: '?' }, + Equal: { key: '^', keyCode: 221, shiftKey: '`', deadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' }, shiftDeadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' } }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyW: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: 'ü', keyCode: 186, shiftKey: 'è' }, + BracketRight: { key: '¨', keyCode: 192, shiftKey: '!', deadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '¨' } }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: 'ö', keyCode: 222, shiftKey: 'é' }, + Quote: { key: 'ä', keyCode: 220, shiftKey: 'à' }, + Backslash: { key: '$', keyCode: 223, shiftKey: '£' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, + KeyZ: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Comma: { key: ',', keyCode: 188, shiftKey: ';' }, + Period: { key: '.', keyCode: 190, shiftKey: ':' }, + Slash: { key: '-', keyCode: 189, shiftKey: '_' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000809.ts b/packages/playwright-core/src/server/keyboards/layouts/00000809.ts new file mode 100644 index 00000000000000..8eae33c590a9ef --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00000809.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00000809 - British +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '`', keyCode: 223, shiftKey: '¬' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '!' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '£' }, + Digit4: { key: '4', keyCode: 52, shiftKey: '$' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '^' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '&' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '*' }, + Digit9: { key: '9', keyCode: 57, shiftKey: '(' }, + Digit0: { key: '0', keyCode: 48, shiftKey: ')' }, + Minus: { key: '-', keyCode: 189, shiftKey: '_' }, + Equal: { key: '=', keyCode: 187, shiftKey: '+' }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyW: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: '[', keyCode: 219, shiftKey: '{' }, + BracketRight: { key: ']', keyCode: 221, shiftKey: '}' }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: ';', keyCode: 186, shiftKey: ':' }, + Quote: { key: '\'', keyCode: 192, shiftKey: '@' }, + Backslash: { key: '#', keyCode: 222, shiftKey: '~' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '\\', keyCode: 220, shiftKey: '|' }, + KeyZ: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Comma: { key: ',', keyCode: 188, shiftKey: '<' }, + Period: { key: '.', keyCode: 190, shiftKey: '>' }, + Slash: { key: '/', keyCode: 191, shiftKey: '?' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/0000080A.ts b/packages/playwright-core/src/server/keyboards/layouts/0000080A.ts index f2087e27ea53ef..50b76235a8568d 100644 --- a/packages/playwright-core/src/server/keyboards/layouts/0000080A.ts +++ b/packages/playwright-core/src/server/keyboards/layouts/0000080A.ts @@ -18,7 +18,7 @@ import type { KeyboardLayout } from '../types'; -// KLID 0000080A - Latin American keyboard +// KLID 0000080A - Spanish (Latin America) const keyboardLayout: KeyboardLayout = { Escape: { key: 'Escape', keyCode: 27 }, F1: { key: 'F1', keyCode: 112 }, @@ -58,7 +58,7 @@ const keyboardLayout: KeyboardLayout = { KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, - BracketLeft: { key: '´', keyCode: 186, shiftKey: '¨' }, + BracketLeft: { key: '´', keyCode: 186, shiftKey: '¨', deadKeyMappings: { 'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú', 'y': 'ý', 'A': 'Á', 'E': 'É', 'I': 'Í', 'O': 'Ó', 'U': 'Ú', 'Y': 'Ý', 'C': 'Ç', 'c': 'ç', ' ': '´' }, shiftDeadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '¨' } }, BracketRight: { key: '+', keyCode: 187, shiftKey: '*' }, Enter: { key: 'Enter', keyCode: 13, text: '\r' }, CapsLock: { key: 'CapsLock', keyCode: 20 }, diff --git a/packages/playwright-core/src/server/keyboards/layouts/00000816.ts b/packages/playwright-core/src/server/keyboards/layouts/00000816.ts index 56ff9405ad7183..b685f50d80d948 100644 --- a/packages/playwright-core/src/server/keyboards/layouts/00000816.ts +++ b/packages/playwright-core/src/server/keyboards/layouts/00000816.ts @@ -18,7 +18,7 @@ import type { KeyboardLayout } from '../types'; -// KLID 00000816 - Portuguese keyboard +// KLID 00000816 - Portuguese (Portugal) const keyboardLayout: KeyboardLayout = { Escape: { key: 'Escape', keyCode: 27 }, F1: { key: 'F1', keyCode: 112 }, @@ -59,7 +59,7 @@ const keyboardLayout: KeyboardLayout = { KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, BracketLeft: { key: '+', keyCode: 187, shiftKey: '*' }, - BracketRight: { key: '´', keyCode: 186, shiftKey: '`' }, + BracketRight: { key: '´', keyCode: 186, shiftKey: '`', deadKeyMappings: { 'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú', 'y': 'ý', 'A': 'Á', 'E': 'É', 'I': 'Í', 'O': 'Ó', 'U': 'Ú', 'Y': 'Ý', ' ': '´' }, shiftDeadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' } }, Enter: { key: 'Enter', keyCode: 13, text: '\r' }, CapsLock: { key: 'CapsLock', keyCode: 20 }, KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, @@ -73,7 +73,7 @@ const keyboardLayout: KeyboardLayout = { KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, Semicolon: { key: 'ç', keyCode: 192, shiftKey: 'Ç' }, Quote: { key: 'º', keyCode: 222, shiftKey: 'ª' }, - Backslash: { key: '~', keyCode: 191, shiftKey: '^' }, + Backslash: { key: '~', keyCode: 191, shiftKey: '^', deadKeyMappings: { 'a': 'ã', 'o': 'õ', 'n': 'ñ', 'A': 'Ã', 'O': 'Õ', 'N': 'Ñ', ' ': '~' }, shiftDeadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' } }, ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, KeyZ: { key: 'z', keyCode: 90, shiftKey: 'Z' }, diff --git a/packages/playwright-core/src/server/keyboards/layouts/0000100C.ts b/packages/playwright-core/src/server/keyboards/layouts/0000100C.ts new file mode 100644 index 00000000000000..6dabcfb92ef9a4 --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/0000100C.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 0000100C - French and Italian (Switzerland) +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '§', keyCode: 191, shiftKey: '°' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '+' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '*' }, + Digit4: { key: '4', keyCode: 52, shiftKey: 'ç' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: '&' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '/' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '(' }, + Digit9: { key: '9', keyCode: 57, shiftKey: ')' }, + Digit0: { key: '0', keyCode: 48, shiftKey: '=' }, + Minus: { key: '\'', keyCode: 219, shiftKey: '?' }, + Equal: { key: '^', keyCode: 221, shiftKey: '`', deadKeyMappings: { 'a': 'â', 'e': 'ê', 'i': 'î', 'o': 'ô', 'u': 'û', 'A': 'Â', 'E': 'Ê', 'I': 'Î', 'O': 'Ô', 'U': 'Û', ' ': '^' }, shiftDeadKeyMappings: { 'a': 'à', 'e': 'è', 'i': 'ì', 'o': 'ò', 'u': 'ù', 'A': 'À', 'E': 'È', 'I': 'Ì', 'O': 'Ò', 'U': 'Ù', ' ': '`' } }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'q', keyCode: 81, shiftKey: 'Q' }, + KeyW: { key: 'w', keyCode: 87, shiftKey: 'W' }, + KeyE: { key: 'e', keyCode: 69, shiftKey: 'E' }, + KeyR: { key: 'r', keyCode: 82, shiftKey: 'R' }, + KeyT: { key: 't', keyCode: 84, shiftKey: 'T' }, + KeyY: { key: 'z', keyCode: 90, shiftKey: 'Z' }, + KeyU: { key: 'u', keyCode: 85, shiftKey: 'U' }, + KeyI: { key: 'i', keyCode: 73, shiftKey: 'I' }, + KeyO: { key: 'o', keyCode: 79, shiftKey: 'O' }, + KeyP: { key: 'p', keyCode: 80, shiftKey: 'P' }, + BracketLeft: { key: 'è', keyCode: 186, shiftKey: 'ü' }, + BracketRight: { key: '¨', keyCode: 192, shiftKey: '!', deadKeyMappings: { 'a': 'ä', 'e': 'ë', 'i': 'ï', 'o': 'ö', 'u': 'ü', 'y': 'ÿ', 'A': 'Ä', 'E': 'Ë', 'I': 'Ï', 'O': 'Ö', 'U': 'Ü', ' ': '"' } }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'a', keyCode: 65, shiftKey: 'A' }, + KeyS: { key: 's', keyCode: 83, shiftKey: 'S' }, + KeyD: { key: 'd', keyCode: 68, shiftKey: 'D' }, + KeyF: { key: 'f', keyCode: 70, shiftKey: 'F' }, + KeyG: { key: 'g', keyCode: 71, shiftKey: 'G' }, + KeyH: { key: 'h', keyCode: 72, shiftKey: 'H' }, + KeyJ: { key: 'j', keyCode: 74, shiftKey: 'J' }, + KeyK: { key: 'k', keyCode: 75, shiftKey: 'K' }, + KeyL: { key: 'l', keyCode: 76, shiftKey: 'L' }, + Semicolon: { key: 'é', keyCode: 222, shiftKey: 'ö' }, + Quote: { key: 'à', keyCode: 220, shiftKey: 'ä' }, + Backslash: { key: '$', keyCode: 223, shiftKey: '£' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: '<', keyCode: 226, shiftKey: '>' }, + KeyZ: { key: 'y', keyCode: 89, shiftKey: 'Y' }, + KeyX: { key: 'x', keyCode: 88, shiftKey: 'X' }, + KeyC: { key: 'c', keyCode: 67, shiftKey: 'C' }, + KeyV: { key: 'v', keyCode: 86, shiftKey: 'V' }, + KeyB: { key: 'b', keyCode: 66, shiftKey: 'B' }, + KeyN: { key: 'n', keyCode: 78, shiftKey: 'N' }, + KeyM: { key: 'm', keyCode: 77, shiftKey: 'M' }, + Comma: { key: ',', keyCode: 188, shiftKey: ';' }, + Period: { key: '.', keyCode: 190, shiftKey: ':' }, + Slash: { key: '-', keyCode: 189, shiftKey: '_' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/layouts/00020422.ts b/packages/playwright-core/src/server/keyboards/layouts/00020422.ts new file mode 100644 index 00000000000000..92ce9790e46c50 --- /dev/null +++ b/packages/playwright-core/src/server/keyboards/layouts/00020422.ts @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated by generate_keyboard_layouts.js, do not edit manually. + +import type { KeyboardLayout } from '../types'; + +// KLID 00020422 - Ukrainian +const keyboardLayout: KeyboardLayout = { + Escape: { key: 'Escape', keyCode: 27 }, + F1: { key: 'F1', keyCode: 112 }, + F2: { key: 'F2', keyCode: 113 }, + F3: { key: 'F3', keyCode: 114 }, + F4: { key: 'F4', keyCode: 115 }, + F5: { key: 'F5', keyCode: 116 }, + F6: { key: 'F6', keyCode: 117 }, + F7: { key: 'F7', keyCode: 118 }, + F8: { key: 'F8', keyCode: 119 }, + F9: { key: 'F9', keyCode: 120 }, + F10: { key: 'F10', keyCode: 121 }, + F11: { key: 'F11', keyCode: 122 }, + F12: { key: 'F12', keyCode: 123 }, + Backquote: { key: '\'', keyCode: 192, shiftKey: '₴' }, + Digit1: { key: '1', keyCode: 49, shiftKey: '!' }, + Digit2: { key: '2', keyCode: 50, shiftKey: '"' }, + Digit3: { key: '3', keyCode: 51, shiftKey: '№' }, + Digit4: { key: '4', keyCode: 52, shiftKey: ';' }, + Digit5: { key: '5', keyCode: 53, shiftKey: '%' }, + Digit6: { key: '6', keyCode: 54, shiftKey: ':' }, + Digit7: { key: '7', keyCode: 55, shiftKey: '?' }, + Digit8: { key: '8', keyCode: 56, shiftKey: '*' }, + Digit9: { key: '9', keyCode: 57, shiftKey: '(' }, + Digit0: { key: '0', keyCode: 48, shiftKey: ')' }, + Minus: { key: '-', keyCode: 189, shiftKey: '_' }, + Equal: { key: '=', keyCode: 187, shiftKey: '+' }, + Backspace: { key: 'Backspace', keyCode: 8 }, + Tab: { key: 'Tab', keyCode: 9 }, + KeyQ: { key: 'й', keyCode: 81, shiftKey: 'Й' }, + KeyW: { key: 'ц', keyCode: 87, shiftKey: 'Ц' }, + KeyE: { key: 'у', keyCode: 69, shiftKey: 'У' }, + KeyR: { key: 'к', keyCode: 82, shiftKey: 'К' }, + KeyT: { key: 'е', keyCode: 84, shiftKey: 'Е' }, + KeyY: { key: 'н', keyCode: 89, shiftKey: 'Н' }, + KeyU: { key: 'г', keyCode: 85, shiftKey: 'Г' }, + KeyI: { key: 'ш', keyCode: 73, shiftKey: 'Ш' }, + KeyO: { key: 'щ', keyCode: 79, shiftKey: 'Щ' }, + KeyP: { key: 'з', keyCode: 80, shiftKey: 'З' }, + BracketLeft: { key: 'х', keyCode: 219, shiftKey: 'Х' }, + BracketRight: { key: 'ї', keyCode: 221, shiftKey: 'Ї' }, + Enter: { key: 'Enter', keyCode: 13, text: '\r' }, + CapsLock: { key: 'CapsLock', keyCode: 20 }, + KeyA: { key: 'ф', keyCode: 65, shiftKey: 'Ф' }, + KeyS: { key: 'і', keyCode: 83, shiftKey: 'І' }, + KeyD: { key: 'в', keyCode: 68, shiftKey: 'В' }, + KeyF: { key: 'а', keyCode: 70, shiftKey: 'А' }, + KeyG: { key: 'п', keyCode: 71, shiftKey: 'П' }, + KeyH: { key: 'р', keyCode: 72, shiftKey: 'Р' }, + KeyJ: { key: 'о', keyCode: 74, shiftKey: 'О' }, + KeyK: { key: 'л', keyCode: 75, shiftKey: 'Л' }, + KeyL: { key: 'д', keyCode: 76, shiftKey: 'Д' }, + Semicolon: { key: 'ж', keyCode: 186, shiftKey: 'Ж' }, + Quote: { key: 'є', keyCode: 222, shiftKey: 'Є' }, + Backslash: { key: '\\', keyCode: 220, shiftKey: '/' }, + ShiftLeft: { key: 'Shift', keyCode: 160, keyCodeWithoutLocation: 16, location: 1 }, + IntlBackslash: { key: 'ґ', keyCode: 226, shiftKey: 'Ґ' }, + KeyZ: { key: 'я', keyCode: 90, shiftKey: 'Я' }, + KeyX: { key: 'ч', keyCode: 88, shiftKey: 'Ч' }, + KeyC: { key: 'с', keyCode: 67, shiftKey: 'С' }, + KeyV: { key: 'м', keyCode: 86, shiftKey: 'М' }, + KeyB: { key: 'и', keyCode: 66, shiftKey: 'И' }, + KeyN: { key: 'т', keyCode: 78, shiftKey: 'Т' }, + KeyM: { key: 'ь', keyCode: 77, shiftKey: 'Ь' }, + Comma: { key: 'б', keyCode: 188, shiftKey: 'Б' }, + Period: { key: 'ю', keyCode: 190, shiftKey: 'Ю' }, + Slash: { key: '.', keyCode: 191, shiftKey: ',' }, + ShiftRight: { key: 'Shift', keyCode: 161, keyCodeWithoutLocation: 16, location: 2 }, + ControlLeft: { key: 'Control', keyCode: 162, keyCodeWithoutLocation: 17, location: 1 }, + MetaLeft: { key: 'Meta', keyCode: 91, location: 1 }, + AltLeft: { key: 'Alt', keyCode: 164, keyCodeWithoutLocation: 18, location: 1 }, + Space: { key: ' ', keyCode: 32 }, + AltRight: { key: 'Alt', keyCode: 165, keyCodeWithoutLocation: 18, location: 2 }, + AltGraph: { key: 'AltGraph', keyCode: 225 }, + MetaRight: { key: 'Meta', keyCode: 92, location: 2 }, + ContextMenu: { key: 'ContextMenu', keyCode: 93 }, + ControlRight: { key: 'Control', keyCode: 163, keyCodeWithoutLocation: 17, location: 2 }, + PrintScreen: { key: 'PrintScreen', keyCode: 44 }, + ScrollLock: { key: 'ScrollLock', keyCode: 145 }, + Pause: { key: 'Pause', keyCode: 19 }, + PageUp: { key: 'PageUp', keyCode: 33 }, + PageDown: { key: 'PageDown', keyCode: 34 }, + Insert: { key: 'Insert', keyCode: 45 }, + Delete: { key: 'Delete', keyCode: 46 }, + Home: { key: 'Home', keyCode: 36 }, + End: { key: 'End', keyCode: 35 }, + ArrowLeft: { key: 'ArrowLeft', keyCode: 37 }, + ArrowUp: { key: 'ArrowUp', keyCode: 38 }, + ArrowRight: { key: 'ArrowRight', keyCode: 39 }, + ArrowDown: { key: 'ArrowDown', keyCode: 40 }, + NumLock: { key: 'NumLock', keyCode: 144 }, + NumpadDivide: { key: '/', keyCode: 111, location: 3 }, + NumpadMultiply: { key: '*', keyCode: 106, location: 3 }, + NumpadSubtract: { key: '-', keyCode: 109, location: 3 }, + Numpad7: { key: 'Home', keyCode: 36, shiftKey: '7', shiftKeyCode: 103, location: 3 }, + Numpad8: { key: 'ArrowUp', keyCode: 38, shiftKey: '8', shiftKeyCode: 104, location: 3 }, + Numpad9: { key: 'PageUp', keyCode: 33, shiftKey: '9', shiftKeyCode: 105, location: 3 }, + Numpad4: { key: 'ArrowLeft', keyCode: 37, shiftKey: '4', shiftKeyCode: 100, location: 3 }, + Numpad5: { key: 'Clear', keyCode: 12, shiftKey: '5', shiftKeyCode: 101, location: 3 }, + Numpad6: { key: 'ArrowRight', keyCode: 39, shiftKey: '6', shiftKeyCode: 102, location: 3 }, + NumpadAdd: { key: '+', keyCode: 107, location: 3 }, + Numpad1: { key: 'End', keyCode: 35, shiftKey: '1', shiftKeyCode: 97, location: 3 }, + Numpad2: { key: 'ArrowDown', keyCode: 40, shiftKey: '2', shiftKeyCode: 98, location: 3 }, + Numpad3: { key: 'PageDown', keyCode: 34, shiftKey: '3', shiftKeyCode: 99, location: 3 }, + Numpad0: { key: 'Insert', keyCode: 45, shiftKey: '0', shiftKeyCode: 96, location: 3 }, + NumpadDecimal: { key: '\u0000', keyCode: 46, shiftKey: '.', shiftKeyCode: 110, location: 3 }, + NumpadEnter: { key: 'Enter', keyCode: 13, text: '\r', location: 3 }, +}; + +export default keyboardLayout; diff --git a/packages/playwright-core/src/server/keyboards/types.ts b/packages/playwright-core/src/server/keyboards/types.ts index b4ac057f640b05..ceadd3c7972fe9 100644 --- a/packages/playwright-core/src/server/keyboards/types.ts +++ b/packages/playwright-core/src/server/keyboards/types.ts @@ -22,6 +22,8 @@ export type KeyDefinition = { shiftKeyCode?: number; text?: string; location?: number; + deadKeyMappings?: Record; + shiftDeadKeyMappings?: Record; }; export type KeyboardLayout = Record; diff --git a/packages/playwright-core/src/server/webkit/wkInput.ts b/packages/playwright-core/src/server/webkit/wkInput.ts index 0732f246d1bffc..60be7663717df1 100644 --- a/packages/playwright-core/src/server/webkit/wkInput.ts +++ b/packages/playwright-core/src/server/webkit/wkInput.ts @@ -70,6 +70,8 @@ export class RawKeyboardImpl implements input.RawKeyboard { let commands = macEditingCommands[shortcut]; if (isString(commands)) commands = [commands]; + if (key === 'Dead') + text = ''; await this._pageProxySession.send('Input.dispatchKeyEvent', { type: 'keyDown', modifiers: toModifiersMask(modifiers), diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index c46867d787cbe3..d31ee0c26a5636 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -12752,12 +12752,21 @@ export interface BrowserType { * * | Values | Name | * | :- | :- | - * | `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | - * | `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | - * | `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | - * | `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | - * | `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | - * | `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | + * | `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | + * | `ar`, `ar-SA`, `ara` | [Arabic](https://learn.microsoft.com/en-us/globalization/keyboards/kbda1) | + * | `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | + * | `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | + * | `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | + * | `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | + * | `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | + * | `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | + * | `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | + * | `es`, `es-ES` | [Spanish and Catalan](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | + * | `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | + * | `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | + * | `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | */ keyboardLayout?: string; @@ -14173,12 +14182,21 @@ export interface AndroidDevice { * * | Values | Name | * | :- | :- | - * | `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | - * | `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | - * | `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | - * | `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | - * | `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | - * | `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | + * | `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | + * | `ar`, `ar-SA`, `ara` | [Arabic](https://learn.microsoft.com/en-us/globalization/keyboards/kbda1) | + * | `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | + * | `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | + * | `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | + * | `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | + * | `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | + * | `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | + * | `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | + * | `es`, `es-ES` | [Spanish and Catalan](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | + * | `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | + * | `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | + * | `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | */ keyboardLayout?: string; @@ -16062,12 +16080,21 @@ export interface Browser extends EventEmitter { * * | Values | Name | * | :- | :- | - * | `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | - * | `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | - * | `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | - * | `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | - * | `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | - * | `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | + * | `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | + * | `ar`, `ar-SA`, `ara` | [Arabic](https://learn.microsoft.com/en-us/globalization/keyboards/kbda1) | + * | `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | + * | `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | + * | `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | + * | `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | + * | `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | + * | `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | + * | `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | + * | `es`, `es-ES` | [Spanish and Catalan](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | + * | `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | + * | `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | + * | `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | */ keyboardLayout?: string; @@ -16946,12 +16973,21 @@ export interface Electron { * * | Values | Name | * | :- | :- | - * | `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | - * | `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | - * | `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | - * | `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | - * | `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | - * | `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | + * | `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | + * | `ar`, `ar-SA`, `ara` | [Arabic](https://learn.microsoft.com/en-us/globalization/keyboards/kbda1) | + * | `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | + * | `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | + * | `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | + * | `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | + * | `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | + * | `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | + * | `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | + * | `es`, `es-ES` | [Spanish and Catalan](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | + * | `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | + * | `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | + * | `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | */ keyboardLayout?: string; @@ -17605,12 +17641,21 @@ export interface Keyboard { * * | Values | Name | * | :- | :- | - * | `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | - * | `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | - * | `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | - * | `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | - * | `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | - * | `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | + * | `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | + * | `ar`, `ar-SA`, `ara` | [Arabic](https://learn.microsoft.com/en-us/globalization/keyboards/kbda1) | + * | `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | + * | `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | + * | `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | + * | `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | + * | `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | + * | `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | + * | `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | + * | `es`, `es-ES` | [Spanish and Catalan](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | + * | `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | + * | `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | + * | `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | */ changeLayout(layoutName: string): Promise; @@ -19242,12 +19287,21 @@ export interface BrowserContextOptions { * * | Values | Name | * | :- | :- | - * | `us`, `en-US` | [US keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | - * | `es`, `es-ES` | [Spanish keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | - * | `br`, `pt-BR` | [Portuguese (Brazil ABNT) keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdbr_1) | - * | `latam`, `es-MX` | [Latin American keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | - * | `pt`, `pt-PT` | [Portuguese keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | - * | `el`, `el-GR` | [Greek keyboard](https://learn.microsoft.com/en-us/globalization/keyboards/kbdhe) | + * | `us`, `en-US` | [US English](https://learn.microsoft.com/en-us/globalization/keyboards/kbdus_7) | + * | `ar`, `ar-SA`, `ara` | [Arabic](https://learn.microsoft.com/en-us/globalization/keyboards/kbda1) | + * | `gb`, `en-GB` | [British](https://learn.microsoft.com/en-us/globalization/keyboards/kbduk) | + * | `dk`, `da-DK` | [Danish](https://learn.microsoft.com/en-us/globalization/keyboards/kbdda) | + * | `fr`, `fr-FR` | [French](https://learn.microsoft.com/en-us/globalization/keyboards/kbdfr) | + * | `de`, `de-DE` | [German](https://learn.microsoft.com/en-us/globalization/keyboards/kbdgr) | + * | `it`, `it-IT` | [Italian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdit) | + * | `pt`, `pt-PT` | [Portuguese (Portugal)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `br`, `pt-BR` | [Portuguese (Brazil)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdpo) | + * | `ru`, `ru-RU` | [Russian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdru) | + * | `ua`, `uk-UA` | [Ukrainian](https://learn.microsoft.com/en-us/globalization/keyboards/kbdur1) | + * | `es`, `es-ES` | [Spanish and Catalan](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsp) | + * | `latam` | [Spanish (Latin America)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdla) | + * | `ch`, `de-CH` | [German (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsg) | + * | `fr-CH`, `it-CH` | [French and Italian (Switzerland)](https://learn.microsoft.com/en-us/globalization/keyboards/kbdsf_2) | */ keyboardLayout?: string; diff --git a/tests/android/browser.spec.ts b/tests/android/browser.spec.ts index a7d126587f6f69..8943f5bc47fecd 100644 --- a/tests/android/browser.spec.ts +++ b/tests/android/browser.spec.ts @@ -119,13 +119,13 @@ test('should be able to pass context options', async ({ androidDevice, httpsServ }); test('should set keyboard layout on android', async function({ androidDevice, server }) { - const context = await androidDevice.launchBrowser({ keyboardLayout: 'el-GR' }); + const context = await androidDevice.launchBrowser({ keyboardLayout: 'fr' }); const [page] = context.pages(); await page.goto(server.PREFIX + '/input/keyboard.html'); - await page.keyboard.press('α'); + await page.keyboard.press('q'); expect(await page.evaluate('getResult()')).toBe( - ['Keydown: α KeyA 65 []', - 'Keypress: α KeyA 945 945 []', - 'Keyup: α KeyA 65 []'].join('\n')); + ['Keydown: q KeyA 81 []', + 'Keypress: q KeyA 113 113 []', + 'Keyup: q KeyA 81 []'].join('\n')); await context.close(); }); diff --git a/tests/electron/electron-app.spec.ts b/tests/electron/electron-app.spec.ts index 3df0342148ed3b..388353c64aa81d 100644 --- a/tests/electron/electron-app.spec.ts +++ b/tests/electron/electron-app.spec.ts @@ -223,13 +223,13 @@ test('should return app name / version from manifest', async ({ launchElectronAp }); test('should set keyboard layout on electron app', async ({ launchElectronApp, server }) => { - const electronApp = await launchElectronApp('electron-window-app.js', [], { keyboardLayout: 'el-GR' }); + const electronApp = await launchElectronApp('electron-window-app.js', [], { keyboardLayout: 'fr' }); const page = await electronApp.firstWindow(); await page.goto(server.PREFIX + '/input/keyboard.html'); - await page.keyboard.press('α'); + await page.keyboard.press('q'); expect(await page.evaluate('getResult()')).toBe( - ['Keydown: α KeyA 65 []', - 'Keypress: α KeyA 945 945 []', - 'Keyup: α KeyA 65 []'].join('\n')); + ['Keydown: q KeyA 81 []', + 'Keypress: q KeyA 113 113 []', + 'Keyup: q KeyA 81 []'].join('\n')); await electronApp.close(); }); diff --git a/tests/library/browsercontext-keyboard-layout.spec.ts b/tests/library/browsercontext-keyboard-layout.spec.ts index 8441ab6938eee6..055d4f7a808861 100644 --- a/tests/library/browsercontext-keyboard-layout.spec.ts +++ b/tests/library/browsercontext-keyboard-layout.spec.ts @@ -17,37 +17,37 @@ import { browserTest as it, expect } from '../config/browserTest'; it('should set keyboard layout on Browser.newContext @smoke', async ({ browser, server }) => { - const context = await browser.newContext({ keyboardLayout: 'el-GR' }); + const context = await browser.newContext({ keyboardLayout: 'fr' }); const page = await context.newPage(); await page.goto(server.PREFIX + '/input/keyboard.html'); - await page.keyboard.press('α'); + await page.keyboard.press('q'); expect(await page.evaluate('getResult()')).toBe( - ['Keydown: α KeyA 65 []', - 'Keypress: α KeyA 945 945 []', - 'Keyup: α KeyA 65 []'].join('\n')); + ['Keydown: q KeyA 81 []', + 'Keypress: q KeyA 113 113 []', + 'Keyup: q KeyA 81 []'].join('\n')); await context.close(); }); it('should set keyboard layout on Browser.newPage @smoke', async ({ browser, server }) => { - const page = await browser.newPage({ keyboardLayout: 'el-GR' }); + const page = await browser.newPage({ keyboardLayout: 'fr' }); await page.goto(server.PREFIX + '/input/keyboard.html'); - await page.keyboard.press('α'); + await page.keyboard.press('q'); expect(await page.evaluate('getResult()')).toBe( - ['Keydown: α KeyA 65 []', - 'Keypress: α KeyA 945 945 []', - 'Keyup: α KeyA 65 []'].join('\n')); + ['Keydown: q KeyA 81 []', + 'Keypress: q KeyA 113 113 []', + 'Keyup: q KeyA 81 []'].join('\n')); await page.close(); }); it('should set keyboard layout on BrowserType.launchPersistentContext @smoke', async ({ browserType, server, createUserDataDir }) => { const userDataDir = await createUserDataDir(); - const context = await browserType.launchPersistentContext(userDataDir, { keyboardLayout: 'el-GR' }); + const context = await browserType.launchPersistentContext(userDataDir, { keyboardLayout: 'fr' }); const page = await context.newPage(); await page.goto(server.PREFIX + '/input/keyboard.html'); - await page.keyboard.press('α'); + await page.keyboard.press('q'); expect(await page.evaluate('getResult()')).toBe( - ['Keydown: α KeyA 65 []', - 'Keypress: α KeyA 945 945 []', - 'Keyup: α KeyA 65 []'].join('\n')); + ['Keydown: q KeyA 81 []', + 'Keypress: q KeyA 113 113 []', + 'Keyup: q KeyA 81 []'].join('\n')); await context.close(); }); diff --git a/tests/page/page-keyboard-layouts.spec.ts b/tests/page/page-keyboard-layouts.spec.ts index 09958af5947e0d..2f813443794f7b 100644 --- a/tests/page/page-keyboard-layouts.spec.ts +++ b/tests/page/page-keyboard-layouts.spec.ts @@ -16,111 +16,166 @@ import { test as it, expect } from './pageTest'; -it.describe(`greek keyboard layout`, () => { - it.beforeEach(async ({ page, server }) => { - await page.keyboard.changeLayout('el-GR'); - await page.goto(server.PREFIX + '/input/keyboard.html'); - }); - - it(`should fire key events on α`, async ({ page }) => { - await page.keyboard.press('α'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: α KeyA 65 []', - 'Keypress: α KeyA 945 945 []', - 'Keyup: α KeyA 65 []'].join('\n')); - }); - - it(`should type ε on KeyE`, async ({ page }) => { - await page.keyboard.press('KeyE'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: ε KeyE 69 []', - 'Keypress: ε KeyE 949 949 []', - 'Keyup: ε KeyE 69 []'].join('\n')); - }); - - it(`should fire key events on Σ`, async ({ page }) => { - await page.keyboard.press('Σ'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: Σ KeyS 83 []', - 'Keypress: Σ KeyS 931 931 []', - 'Keyup: Σ KeyS 83 []'].join('\n')); - }); +function removeAccents(str: string) { + return str.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); +} - it(`should type Δ on Shift+KeyD`, async ({ page }) => { - await page.keyboard.press('Shift+KeyD'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: Shift ShiftLeft 16 [Shift]', - 'Keydown: Δ KeyD 68 [Shift]', - 'Keypress: Δ KeyD 916 916 [Shift]', - 'Keyup: Δ KeyD 68 [Shift]', - 'Keyup: Shift ShiftLeft 16 []'].join('\n')); - await expect(page.locator('textarea')).toHaveValue('Δ'); - }); +it.beforeEach(async ({ page, server }) => { + await page.goto(server.PREFIX + '/input/keyboard.html'); }); -it.describe(`portuguese keyboard layout`, () => { - it.beforeEach(async ({ page, server }) => { - await page.keyboard.changeLayout('pt-PT'); - await page.goto(server.PREFIX + '/input/keyboard.html'); +for (const fn of ['press', 'down', 'up']) { + it(`should throw exception on ${fn} with accented key`, async ({ page }) => { + await page.keyboard.changeLayout('pt'); + await expect(async () => await page.keyboard[fn]('á')).rejects.toThrowError(`Accented key not supported: "á"`); }); - it(`should type backslash on Backquote`, async ({ page }) => { - await page.keyboard.press('Backquote'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: \\ Backquote 220 []', - 'Keypress: \\ Backquote 92 92 []', - 'Keyup: \\ Backquote 220 []'].join('\n')); + it(`should throw exception on ${fn} with shifted accented key`, async ({ page }) => { + await page.keyboard.changeLayout('pt'); + await expect(async () => await page.keyboard[fn]('à')).rejects.toThrowError(`Accented key not supported: "à"`); }); +} - it(`should type ! on Shift+Digit1`, async ({ page }) => { - await page.keyboard.press('Shift+Digit1'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: Shift ShiftLeft 16 [Shift]', - 'Keydown: ! Digit1 49 [Shift]', - 'Keypress: ! Digit1 33 33 [Shift]', - 'Keyup: ! Digit1 49 [Shift]', - 'Keyup: Shift ShiftLeft 16 []'].join('\n')); - }); +it(`should handle dead key`, async ({ page }) => { + await page.keyboard.changeLayout('pt'); + await page.keyboard.press('BracketRight'); + await expect(page.locator('textarea')).toHaveValue(''); + expect(await page.evaluate('getResult()')).toBe( + ['Keydown: Dead BracketRight 186 []', + 'Keyup: Dead BracketRight 186 []',].join('\n')); }); -it.describe(`us keyboard layout`, () => { - it.beforeEach(async ({ page, server }) => { - await page.keyboard.changeLayout('en-US'); - await page.goto(server.PREFIX + '/input/keyboard.html'); - }); - - it(`should type backslash on Backslash`, async ({ page }) => { - await page.keyboard.press('Backslash'); - expect(await page.evaluate('getResult()')).toBe( - ['Keydown: \\ Backslash 220 []', - 'Keypress: \\ Backslash 92 92 []', - 'Keyup: \\ Backslash 220 []'].join('\n')); - }); +it(`should handle shifted dead key`, async ({ page }) => { + await page.keyboard.changeLayout('pt'); + await page.keyboard.press('Shift+BracketRight'); + await expect(page.locator('textarea')).toHaveValue(''); + expect(await page.evaluate('getResult()')).toBe( + ['Keydown: Shift ShiftLeft 16 [Shift]', + 'Keydown: Dead BracketRight 186 [Shift]', + 'Keyup: Dead BracketRight 186 [Shift]', + 'Keyup: Shift ShiftLeft 16 []',].join('\n')); }); it(`should throw exception on invalid layout format`, async ({ page }) => { - await expect(async () => await page.keyboard.changeLayout('invalid')).rejects.toThrowError(); + await expect(async () => await page.keyboard.changeLayout('invalid')).rejects.toThrowError(`Keyboard layout name "invalid" not found`); }); -const testData = { - 'en_us': { keyCode: 65, key: 'a' }, - 'el_gr': { keyCode: 65, key: 'α' }, - 'pt_br': { keyCode: 65, key: 'a' }, - 'pt_pt': { keyCode: 65, key: 'a' }, - 'es_mx': { keyCode: 65, key: 'a' }, - 'es_es': { keyCode: 65, key: 'a' }, +// key, code, keyCode +type SimpleKeyTest = [string, string, number]; +// key, deadkeyCode, deadkeyKeyCode, letterCode, letterKeyCode +type AccentedKeyTest = [...SimpleKeyTest, string, number]; + +const testData: Record = { + 'us': [['`', 'Backquote', 192], ['~', 'Shift+Backquote', 192]], + 'gb': [['`', 'Backquote', 223], ['¬', 'Shift+Backquote', 223]], + 'dk': [['ø', 'Quote', 222], ['ä', 'BracketRight', 186, 'KeyA', 65], ['â', 'Shift+BracketRight', 186, 'KeyA', 65]], + 'fr': [['q', 'KeyA', 81], ['â', 'BracketLeft', 221, 'KeyQ', 65], ['ä', 'Shift+BracketLeft', 221, 'KeyQ', 65]], + 'de': [['#', 'Backslash', 191], ['á', 'Equal', 221, 'KeyA', 65], ['à', 'Shift+Equal', 221, 'KeyA', 65]], + 'it': [['è', 'BracketLeft', 186], ['é', 'Shift+BracketLeft', 186]], + 'pt': [['\\', 'Backquote', 220], ['á', 'BracketRight', 186, 'KeyA', 65], ['à', 'Shift+BracketRight', 186, 'KeyA', 65]], + 'br': [['\'', 'Backquote', 192], ['á', 'BracketLeft', 219, 'KeyA', 65], ['à', 'Shift+BracketLeft', 219, 'KeyA', 65]], + 'ru': [['ф', 'KeyA', 65], ['э', 'Quote', 222], ['Ф', 'Shift+KeyA', 65]], + 'ua': [['ф', 'KeyA', 65], ['є', 'Quote', 222], ['Ф', 'Shift+KeyA', 65]], + 'es': [['¡', 'Equal', 221], ['à', 'BracketLeft', 186, 'KeyA', 65], ['â', 'Shift+BracketLeft', 186, 'KeyA', 65]], + 'latam': [['¿', 'Equal', 221], ['á', 'BracketLeft', 186, 'KeyA', 65], ['ä', 'Shift+BracketLeft', 186, 'KeyA', 65]], + 'ch': [['ü', 'BracketLeft', 186], ['ô', 'Equal', 221, 'KeyO', 79], ['ò', 'Shift+Equal', 221, 'KeyO', 79]], + 'fr-CH': [['è', 'BracketLeft', 186], ['ô', 'Equal', 221, 'KeyO', 79], ['ò', 'Shift+Equal', 221, 'KeyO', 79]], }; -for (const [locale, { key, keyCode }] of Object.entries(testData)) { - it(`should fire events on KeyA for ${locale} locale`, async ({ page, server }) => { - await page.keyboard.changeLayout(locale); - await page.goto(server.PREFIX + '/input/keyboard.html'); - - await page.keyboard.press('KeyA'); - const charCode = key.charCodeAt(0); - expect(await page.evaluate('getResult()')).toBe( - [`Keydown: ${key} KeyA ${keyCode} []`, - `Keypress: ${key} KeyA ${charCode} ${charCode} []`, - `Keyup: ${key} KeyA ${keyCode} []`].join('\n')); +for (const [locale, test] of Object.entries(testData)) { + it.describe(`${locale} keyboard layout`, () => { + + it.beforeEach(async ({ page }) => { + await page.keyboard.changeLayout(locale); + }); + + for (const [key, code, keyCode, letterCode, letterKeyCode] of test) { + + if (!letterCode) { + + it(`should fire events on ${code}`, async ({ page }) => { + const [shifted, unshitedCode] = code.startsWith('Shift+') ? [true, code.substring('Shift+'.length)] : [false, code]; + await page.keyboard.press(code); + const charCode = key.charCodeAt(0); + const result = await page.evaluate('getResult()'); + if (shifted) { + expect(result).toBe( + ['Keydown: Shift ShiftLeft 16 [Shift]', + `Keydown: ${key} ${unshitedCode} ${keyCode} [Shift]`, + `Keypress: ${key} ${unshitedCode} ${charCode} ${charCode} [Shift]`, + `Keyup: ${key} ${unshitedCode} ${keyCode} [Shift]`, + 'Keyup: Shift ShiftLeft 16 []'].join('\n')); + } else { + expect(result).toBe( + [`Keydown: ${key} ${unshitedCode} ${keyCode} []`, + `Keypress: ${key} ${unshitedCode} ${charCode} ${charCode} []`, + `Keyup: ${key} ${unshitedCode} ${keyCode} []`].join('\n')); + } + }); + + it(`should fire events on "${key}"`, async ({ page }) => { + const unshitedCode = code.startsWith('Shift+') ? code.substring('Shift+'.length) : code; + await page.keyboard.press(key); + const charCode = key.charCodeAt(0); + const result = await page.evaluate('getResult()'); + // TODO shouldn't it also send a Shift event? + expect(result).toBe( + [`Keydown: ${key} ${unshitedCode} ${keyCode} []`, + `Keypress: ${key} ${unshitedCode} ${charCode} ${charCode} []`, + `Keyup: ${key} ${unshitedCode} ${keyCode} []`].join('\n')); + }); + } else { + + it(`should fire events in accented key for ${code} ${letterCode}`, async ({ page }) => { + const [shifted, unshitedCode] = code.startsWith('Shift+') ? [true, code.substring('Shift+'.length)] : [false, code]; + await page.keyboard.press(code); + await page.keyboard.press(letterCode); + const charCode = key.charCodeAt(0); + const results = await page.evaluate('getResult()'); + if (!shifted) { + expect(results).toBe( + [`Keydown: Dead ${unshitedCode} ${keyCode} []`, + `Keyup: Dead ${unshitedCode} ${keyCode} []`, + `Keydown: ${key} ${letterCode} ${letterKeyCode} []`, + `Keypress: ${key} ${letterCode} ${charCode} ${charCode} []`, + `Keyup: ${removeAccents(key)} ${letterCode} ${letterKeyCode} []`].join('\n')); + } else { + expect(results).toBe( + [`Keydown: Shift ShiftLeft 16 [Shift]`, + `Keydown: Dead ${unshitedCode} ${keyCode} [Shift]`, + `Keyup: Dead ${unshitedCode} ${keyCode} [Shift]`, + `Keyup: Shift ShiftLeft 16 []`, + `Keydown: ${key} ${letterCode} ${letterKeyCode} []`, + `Keypress: ${key} ${letterCode} ${charCode} ${charCode} []`, + `Keyup: ${removeAccents(key)} ${letterCode} ${letterKeyCode} []`,].join('\n')); + } + }); + + it(`should fire events when typing accented key "${key}"`, async ({ page }) => { + const [shifted, unshitedCode] = code.startsWith('Shift+') ? [true, code.substring('Shift+'.length)] : [false, code]; + await page.keyboard.type(key); + const charCode = key.charCodeAt(0); + const results = await page.evaluate('getResult()'); + if (!shifted) { + expect(results).toBe( + [`Keydown: Dead ${unshitedCode} ${keyCode} []`, + `Keyup: Dead ${unshitedCode} ${keyCode} []`, + `Keydown: ${key} ${letterCode} ${letterKeyCode} []`, + `Keypress: ${key} ${letterCode} ${charCode} ${charCode} []`, + `Keyup: ${removeAccents(key)} ${letterCode} ${letterKeyCode} []`].join('\n')); + } else { + expect(results).toBe( + [`Keydown: Shift ShiftLeft 16 [Shift]`, + `Keydown: Dead ${unshitedCode} ${keyCode} [Shift]`, + `Keyup: Dead ${unshitedCode} ${keyCode} [Shift]`, + `Keyup: Shift ShiftLeft 16 []`, + `Keydown: ${key} ${letterCode} ${letterKeyCode} []`, + `Keypress: ${key} ${letterCode} ${charCode} ${charCode} []`, + `Keyup: ${removeAccents(key)} ${letterCode} ${letterKeyCode} []`,].join('\n')); + } + }); + + } + } }); } diff --git a/utils/generate_keyboard_layouts.js b/utils/generate_keyboard_layouts.js index 7525b15b2031fa..55b1a20e5f860d 100644 --- a/utils/generate_keyboard_layouts.js +++ b/utils/generate_keyboard_layouts.js @@ -206,24 +206,35 @@ async function generate(klid) { /** * scancode to keys - * - * @type {Object.} + * @typedef {{ accent: string, results: Object. }} DeadKey + * @type {Object., shiftDeadKeyMappings?: Object. }>} */ const sc2keys = Object.fromEntries(sc2vkJson.KeyboardLayout.PhysicalKeys[0].PK .map(({ Result, $: { SC } }) => { if (!Result) return; - let key, shiftKey; + let key, shiftKey, deadKeyMappings, shiftDeadKeyMappings; for (const { $, DeadKeyTable } of Result) { const { Text, With } = $ ?? {}; if (With && With !== 'VK_SHIFT') continue; - const text = Text ?? DeadKeyTable?.[0].$.Accent; + let text = Text; + let results; + if (!text && DeadKeyTable?.[0]) { + const { $: { Accent }, Result } = DeadKeyTable[0]; + text = Accent; + results = Object.fromEntries(Result.map(({ $: { Text, With } }) => ([With, Text]))); + }; const isShift = With === 'VK_SHIFT'; - if (!isShift) key = text; - if (isShift) shiftKey = text; + if (!isShift) { + key = text; + deadKeyMappings = results; + } else { + shiftKey = text; + shiftDeadKeyMappings = results; + } } - return [SC.toUpperCase(), { key, shiftKey }]; + return [SC.toUpperCase(), { key, shiftKey, deadKeyMappings, shiftDeadKeyMappings }]; }).filter(Boolean)); const kdbtablesJson = parseXML(kdbtables); @@ -244,14 +255,14 @@ async function generate(klid) { for (const [keyname, def] of Object.entries(keyboardLayoutGenerator)) { if (typeof def === 'number') { const sc = def.toString(16).toUpperCase().padStart(2, '0'); - const { key, shiftKey } = sc2keys[sc] ?? {}; + const { key, shiftKey, deadKeyMappings, shiftDeadKeyMappings } = sc2keys[sc] ?? {}; if (key === shiftKey === undefined) continue; // def is the scancode as number const keyCode = sc2vkCode[def]; - layout[keyname] = { key, keyCode, shiftKey: keyname === 'Space' && key === shiftKey ? undefined : shiftKey }; + layout[keyname] = { key, keyCode, shiftKey: keyname === 'Space' && key === shiftKey ? undefined : shiftKey, deadKeyMappings, shiftDeadKeyMappings }; } else { layout[keyname] = def; } @@ -266,23 +277,25 @@ function fixQuotes(str) { return strBody?.replace(/'/g, `\\'`).replace(/\\"/g, '"'); } +/** @param {Object.} mappings */ +function stringifyDeadKeyMappings(mappings) { + const resultsProps = Object.entries(mappings).map(([k, v]) => `'${fixQuotes(k)}': '${fixQuotes(v)}'`); + return `{ ${resultsProps.join(', ')} }`; +} + /** @param {KeyDefinition} def */ function stringifyKeyDefinition(def) { - const escaped = { - ...def, - key: fixQuotes(def.key), - shiftKey: fixQuotes(def.shiftKey), - text: fixQuotes(def.text), - }; /** @type {string[]} */ const propStrs = []; - if (escaped.key !== undefined) propStrs.push(`key: '${escaped.key}'`); - if (escaped.keyCode !== undefined) propStrs.push(`keyCode: ${escaped.keyCode}`); - if (escaped.keyCodeWithoutLocation !== undefined) propStrs.push(`keyCodeWithoutLocation: ${escaped.keyCodeWithoutLocation}`); - if (escaped.shiftKey !== undefined) propStrs.push(`shiftKey: '${escaped.shiftKey}'`); - if (escaped.shiftKeyCode !== undefined) propStrs.push(`shiftKeyCode: ${escaped.shiftKeyCode}`); - if (escaped.text !== undefined) propStrs.push(`text: '${escaped.text}'`); - if (escaped.location !== undefined) propStrs.push(`location: ${escaped.location}`); + if (def.key !== undefined) propStrs.push(`key: '${fixQuotes(def.key)}'`); + if (def.keyCode !== undefined) propStrs.push(`keyCode: ${def.keyCode}`); + if (def.keyCodeWithoutLocation !== undefined) propStrs.push(`keyCodeWithoutLocation: ${def.keyCodeWithoutLocation}`); + if (def.shiftKey !== undefined) propStrs.push(`shiftKey: '${fixQuotes(def.shiftKey)}'`); + if (def.shiftKeyCode !== undefined) propStrs.push(`shiftKeyCode: ${def.shiftKeyCode}`); + if (def.text !== undefined) propStrs.push(`text: '${fixQuotes(def.text)}'`); + if (def.location !== undefined) propStrs.push(`location: ${def.location}`); + if (def.deadKeyMappings !== undefined) propStrs.push(`deadKeyMappings: ${stringifyDeadKeyMappings(def.deadKeyMappings)}`); + if (def.shiftDeadKeyMappings !== undefined) propStrs.push(`shiftDeadKeyMappings: ${stringifyDeadKeyMappings(def.shiftDeadKeyMappings)}`); return `{ ${propStrs.join(', ')} }`; }