Skip to content

🎥 Make videos programmatically with React

JSHandle

Jonny Burger53176dab71aa
diff --git a/packages/renderer/src/browser/Input.ts b/packages/renderer/src/browser/Input.ts
deleted file mode 100644
index 9fee2aaa5f..0000000000
--- a/packages/renderer/src/browser/Input.ts
+++ /dev/null
@@ -1,666 +0,0 @@
-/**
- * Copyright 2017 Google Inc. All rights reserved.
- *
- * 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.
- */
-
-import {Protocol} from 'devtools-protocol';
-import {assert} from './assert';
-import {CDPSession} from './Connection';
-import {Point} from './JSHandle';
-import {KeyDefinition, KeyInput, _keyDefinitions} from './USKeyboardLayout';
-
-type KeyDescription = Required<
- Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>
->;
-
-/**
- * Keyboard provides an api for managing a virtual keyboard.
- * The high level api is {@link Keyboard."type"},
- * which takes raw characters and generates proper keydown, keypress/input,
- * and keyup events on your page.
- *
- * @remarks
- * For finer control, you can use {@link Keyboard.down},
- * {@link Keyboard.up}, and {@link Keyboard.sendCharacter}
- * to manually fire events as if they were generated from a real keyboard.
- *
- * On MacOS, keyboard shortcuts like `⌘ A` -\> Select All do not work.
- * See {@link https://github.com/puppeteer/puppeteer/issues/1313 | #1313}.
- *
- * @example
- * An example of holding down `Shift` in order to select and delete some text:
- * ```js
- * await page.keyboard.type('Hello World!');
- * await page.keyboard.press('ArrowLeft');
- *
- * await page.keyboard.down('Shift');
- * for (let i = 0; i < ' World'.length; i++)
- * await page.keyboard.press('ArrowLeft');
- * await page.keyboard.up('Shift');
- *
- * await page.keyboard.press('Backspace');
- * // Result text will end up saying 'Hello!'
- * ```
- *
- * @example
- * An example of pressing `A`
- * ```js
- * await page.keyboard.down('Shift');
- * await page.keyboard.press('KeyA');
- * await page.keyboard.up('Shift');
- * ```
- *
- * @public
- */
-export class Keyboard {
- #client: CDPSession;
- #pressedKeys = new Set<string>();
-
- /**
- * @internal
- */
- _modifiers = 0;
-
- /**
- * @internal
- */
- constructor(client: CDPSession) {
- this.#client = client;
- }
-
- /**
- * Dispatches a `keydown` event.
- *
- * @remarks
- * If `key` is a single character and no modifier keys besides `Shift`
- * are being held down, a `keypress`/`input` event will also generated.
- * The `text` option can be specified to force an input event to be generated.
- * If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`,
- * subsequent key presses will be sent with that modifier active.
- * To release the modifier key, use {@link Keyboard.up}.
- *
- * After the key is pressed once, subsequent calls to
- * {@link Keyboard.down} will have
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat | repeat}
- * set to true. To release the key, use {@link Keyboard.up}.
- *
- * Modifier keys DO influence {@link Keyboard.down}.
- * Holding down `Shift` will type the text in upper case.
- *
- * @param key - Name of key to press, such as `ArrowLeft`.
- * See {@link KeyInput} for a list of all key names.
- *
- * @param options - An object of options. Accepts text which, if specified,
- * generates an input event with this text.
- */
- async down(
- key: KeyInput,
- options: {text?: string} = {text: undefined}
- ): Promise<void> {
- const description = this.#keyDescriptionForString(key);
-
- const autoRepeat = this.#pressedKeys.has(description.code);
- this.#pressedKeys.add(description.code);
- this._modifiers |= this.#modifierBit(description.key);
-
- const text = options.text === undefined ? description.text : options.text;
- await this.#client.send('Input.dispatchKeyEvent', {
- type: text ? 'keyDown' : 'rawKeyDown',
- modifiers: this._modifiers,
- windowsVirtualKeyCode: description.keyCode,
- code: description.code,
- key: description.key,
- text,
- unmodifiedText: text,
- autoRepeat,
- location: description.location,
- isKeypad: description.location === 3,
- });
- }
-
- #modifierBit(key: string): number {
- if (key === 'Alt') {
- return 1;
- }
-
- if (key === 'Control') {
- return 2;
- }
-
- if (key === 'Meta') {
- return 4;
- }
-
- if (key === 'Shift') {
- return 8;
- }
-
- return 0;
- }
-
- #keyDescriptionForString(keyString: KeyInput): KeyDescription {
- const shift = this._modifiers & 8;
- const description = {
- key: '',
- keyCode: 0,
- code: '',
- text: '',
- location: 0,
- };
-
- const definition = _keyDefinitions[keyString];
- assert(definition, `Unknown key: "${keyString}"`);
-
- if (definition.key) {
- description.key = definition.key;
- }
-
- if (shift && definition.shiftKey) {
- description.key = definition.shiftKey;
- }
-
- if (definition.keyCode) {
- description.keyCode = definition.keyCode;
- }
-
- if (shift && definition.shiftKeyCode) {
- description.keyCode = definition.shiftKeyCode;
- }
-
- if (definition.code) {
- description.code = definition.code;
- }
-
- if (definition.location) {
- description.location = definition.location;
- }
-
- if (description.key.length === 1) {
- description.text = description.key;
- }
-
- if (definition.text) {
- description.text = definition.text;
- }
-
- if (shift && definition.shiftText) {
- description.text = definition.shiftText;
- }
-
- // if any modifiers besides shift are pressed, no text should be sent
- if (this._modifiers & ~8) {
- description.text = '';
- }
-
- return description;
- }
-
- /**
- * Dispatches a `keyup` event.
- *
- * @param key - Name of key to release, such as `ArrowLeft`.
- * See {@link KeyInput | KeyInput}
- * for a list of all key names.
- */
- async up(key: KeyInput): Promise<void> {
- const description = this.#keyDescriptionForString(key);
-
- this._modifiers &= ~this.#modifierBit(description.key);
- this.#pressedKeys.delete(description.code);
- await this.#client.send('Input.dispatchKeyEvent', {
- type: 'keyUp',
- modifiers: this._modifiers,
- key: description.key,
- windowsVirtualKeyCode: description.keyCode,
- code: description.code,
- location: description.location,
- });
- }
-
- /**
- * Dispatches a `keypress` and `input` event.
- * This does not send a `keydown` or `keyup` event.
- *
- * @remarks
- * Modifier keys DO NOT effect {@link Keyboard.sendCharacter | Keyboard.sendCharacter}.
- * Holding down `Shift` will not type the text in upper case.
- *
- * @example
- * ```js
- * page.keyboard.sendCharacter('å—¨');
- * ```
- *
- * @param char - Character to send into the page.
- */
- async sendCharacter(char: string): Promise<void> {
- await this.#client.send('Input.insertText', {text: char});
- }
-
- private charIsKey(char: string): char is KeyInput {
- return Boolean(_keyDefinitions[char as KeyInput]);
- }
-
- /**
- * Sends a `keydown`, `keypress`/`input`,
- * and `keyup` event for each character in the text.
- *
- * @remarks
- * To press a special key, like `Control` or `ArrowDown`,
- * use {@link Keyboard.press}.
- *
- * Modifier keys DO NOT effect `keyboard.type`.
- * Holding down `Shift` will not type the text in upper case.
- *
- * @example
- * ```js
- * await page.keyboard.type('Hello'); // Types instantly
- * await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
- * ```
- *
- * @param text - A text to type into a focused element.
- * @param options - An object of options. Accepts delay which,
- * if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
- * Defaults to 0.
- */
- async type(text: string, options: {delay?: number} = {}): Promise<void> {
- const delay = options.delay || undefined;
- for (const char of text) {
- if (this.charIsKey(char)) {
- await this.press(char, {delay});
- } else {
- if (delay) {
- await new Promise((f) => {
- return setTimeout(f, delay);
- });
- }
-
- await this.sendCharacter(char);
- }
- }
- }
-
- /**
- * Shortcut for {@link Keyboard.down}
- * and {@link Keyboard.up}.
- *
- * @remarks
- * If `key` is a single character and no modifier keys besides `Shift`
- * are being held down, a `keypress`/`input` event will also generated.
- * The `text` option can be specified to force an input event to be generated.
- *
- * Modifier keys DO effect {@link Keyboard.press}.
- * Holding down `Shift` will type the text in upper case.
- *
- * @param key - Name of key to press, such as `ArrowLeft`.
- * See {@link KeyInput} for a list of all key names.
- *
- * @param options - An object of options. Accepts text which, if specified,
- * generates an input event with this text. Accepts delay which,
- * if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
- * Defaults to 0.
- */
- async press(
- key: KeyInput,
- options: {delay?: number; text?: string} = {}
- ): Promise<void> {
- const {delay = null} = options;
- await this.down(key, options);
- if (delay) {
- await new Promise((f) => {
- return setTimeout(f, options.delay);
- });
- }
-
- await this.up(key);
- }
-}
-
-/**
- * @public
- */
-export type MouseButton = 'left' | 'right' | 'middle' | 'back' | 'forward';
-
-/**
- * @public
- */
-interface MouseOptions {
- button?: MouseButton;
- clickCount?: number;
-}
-
-/**
- * @public
- */
-interface MouseWheelOptions {
- deltaX?: number;
- deltaY?: number;
-}
-
-/**
- * The Mouse class operates in main-frame CSS pixels
- * relative to the top-left corner of the viewport.
- * @remarks
- * Every `page` object has its own Mouse, accessible with [`page.mouse`](#pagemouse).
- *
- * @example
- * ```js
- * // Using ‘page.mouse’ to trace a 100x100 square.
- * await page.mouse.move(0, 0);
- * await page.mouse.down();
- * await page.mouse.move(0, 100);
- * await page.mouse.move(100, 100);
- * await page.mouse.move(100, 0);
- * await page.mouse.move(0, 0);
- * await page.mouse.up();
- * ```
- *
- * **Note**: The mouse events trigger synthetic `MouseEvent`s.
- * This means that it does not fully replicate the functionality of what a normal user
- * would be able to do with their mouse.
- *
- * For example, dragging and selecting text is not possible using `page.mouse`.
- * Instead, you can use the {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/getSelection | `DocumentOrShadowRoot.getSelection()`} functionality implemented in the platform.
- *
- * @example
- * For example, if you want to select all content between nodes:
- * ```js
- * await page.evaluate((from, to) => {
- * const selection = from.getRootNode().getSelection();
- * const range = document.createRange();
- * range.setStartBefore(from);
- * range.setEndAfter(to);
- * selection.removeAllRanges();
- * selection.addRange(range);
- * }, fromJSHandle, toJSHandle);
- * ```
- * If you then would want to copy-paste your selection, you can use the clipboard api:
- * ```js
- * // The clipboard api does not allow you to copy, unless the tab is focused.
- * await page.bringToFront();
- * await page.evaluate(() => {
- * // Copy the selected content to the clipboard
- * document.execCommand('copy');
- * // Obtain the content of the clipboard as a string
- * return navigator.clipboard.readText();
- * });
- * ```
- * **Note**: If you want access to the clipboard API,
- * you have to give it permission to do so:
- * ```js
- * await browser.defaultBrowserContext().overridePermissions(
- * '<your origin>', ['clipboard-read', 'clipboard-write']
- * );
- * ```
- * @public
- */
-export class Mouse {
- #client: CDPSession;
- #keyboard: Keyboard;
- #x = 0;
- #y = 0;
- #button: MouseButton | 'none' = 'none';
-
- /**
- * @internal
- */
- constructor(client: CDPSession, keyboard: Keyboard) {
- this.#client = client;
- this.#keyboard = keyboard;
- }
-
- /**
- * Dispatches a `mousemove` event.
- * @param x - Horizontal position of the mouse.
- * @param y - Vertical position of the mouse.
- * @param options - Optional object. If specified, the `steps` property
- * sends intermediate `mousemove` events when set to `1` (default).
- */
- async move(
- x: number,
- y: number,
- options: {steps?: number} = {}
- ): Promise<void> {
- const {steps = 1} = options;
- const fromX = this.#x;
- const fromY = this.#y;
- this.#x = x;
- this.#y = y;
- for (let i = 1; i <= steps; i++) {
- await this.#client.send('Input.dispatchMouseEvent', {
- type: 'mouseMoved',
- button: this.#button,
- x: fromX + (this.#x - fromX) * (i / steps),
- y: fromY + (this.#y - fromY) * (i / steps),
- modifiers: this.#keyboard._modifiers,
- });
- }
- }
-
- /**
- * Shortcut for `mouse.move`, `mouse.down` and `mouse.up`.
- * @param x - Horizontal position of the mouse.
- * @param y - Vertical position of the mouse.
- * @param options - Optional `MouseOptions`.
- */
- async click(
- x: number,
- y: number,
- options: MouseOptions & {delay?: number} = {}
- ): Promise<void> {
- const {delay = null} = options;
- if (delay !== null) {
- await this.move(x, y);
- await this.down(options);
- await new Promise((f) => {
- return setTimeout(f, delay);
- });
- await this.up(options);
- } else {
- await this.move(x, y);
- await this.down(options);
- await this.up(options);
- }
- }
-
- /**
- * Dispatches a `mousedown` event.
- * @param options - Optional `MouseOptions`.
- */
- async down(options: MouseOptions = {}): Promise<void> {
- const {button = 'left', clickCount = 1} = options;
- this.#button = button;
- await this.#client.send('Input.dispatchMouseEvent', {
- type: 'mousePressed',
- button,
- x: this.#x,
- y: this.#y,
- modifiers: this.#keyboard._modifiers,
- clickCount,
- });
- }
-
- /**
- * Dispatches a `mouseup` event.
- * @param options - Optional `MouseOptions`.
- */
- async up(options: MouseOptions = {}): Promise<void> {
- const {button = 'left', clickCount = 1} = options;
- this.#button = 'none';
- await this.#client.send('Input.dispatchMouseEvent', {
- type: 'mouseReleased',
- button,
- x: this.#x,
- y: this.#y,
- modifiers: this.#keyboard._modifiers,
- clickCount,
- });
- }
-
- /**
- * Dispatches a `mousewheel` event.
- * @param options - Optional: `MouseWheelOptions`.
- *
- * @example
- * An example of zooming into an element:
- * ```js
- * await page.goto('https://mdn.mozillademos.org/en-US/docs/Web/API/Element/wheel_event$samples/Scaling_an_element_via_the_wheel?revision=1587366');
- *
- * const elem = await page.$('div');
- * const boundingBox = await elem.boundingBox();
- * await page.mouse.move(
- * boundingBox.x + boundingBox.width / 2,
- * boundingBox.y + boundingBox.height / 2
- * );
- *
- * await page.mouse.wheel({ deltaY: -100 })
- * ```
- */
- async wheel(options: MouseWheelOptions = {}): Promise<void> {
- const {deltaX = 0, deltaY = 0} = options;
- await this.#client.send('Input.dispatchMouseEvent', {
- type: 'mouseWheel',
- x: this.#x,
- y: this.#y,
- deltaX,
- deltaY,
- modifiers: this.#keyboard._modifiers,
- pointerType: 'mouse',
- });
- }
-
- /**
- * Dispatches a `drag` event.
- * @param start - starting point for drag
- * @param target - point to drag to
- */
- async drag(start: Point, target: Point): Promise<Protocol.Input.DragData> {
- const promise = new Promise<Protocol.Input.DragData>((resolve) => {
- this.#client.once('Input.dragIntercepted', (event) => {
- return resolve(event.data);
- });
- });
- await this.move(start.x, start.y);
- await this.down();
- await this.move(target.x, target.y);
- return promise;
- }
-
- /**
- * Dispatches a `dragenter` event.
- * @param target - point for emitting `dragenter` event
- * @param data - drag data containing items and operations mask
- */
- async dragEnter(target: Point, data: Protocol.Input.DragData): Promise<void> {
- await this.#client.send('Input.dispatchDragEvent', {
- type: 'dragEnter',
- x: target.x,
- y: target.y,
- modifiers: this.#keyboard._modifiers,
- data,
- });
- }
-
- /**
- * Dispatches a `dragover` event.
- * @param target - point for emitting `dragover` event
- * @param data - drag data containing items and operations mask
- */
- async dragOver(target: Point, data: Protocol.Input.DragData): Promise<void> {
- await this.#client.send('Input.dispatchDragEvent', {
- type: 'dragOver',
- x: target.x,
- y: target.y,
- modifiers: this.#keyboard._modifiers,
- data,
- });
- }
-
- /**
- * Performs a dragenter, dragover, and drop in sequence.
- * @param target - point to drop on
- * @param data - drag data containing items and operations mask
- */
- async drop(target: Point, data: Protocol.Input.DragData): Promise<void> {
- await this.#client.send('Input.dispatchDragEvent', {
- type: 'drop',
- x: target.x,
- y: target.y,
- modifiers: this.#keyboard._modifiers,
- data,
- });
- }
-
- /**
- * Performs a drag, dragenter, dragover, and drop in sequence.
- * @param target - point to drag from
- * @param target - point to drop on
- * @param options - An object of options. Accepts delay which,
- * if specified, is the time to wait between `dragover` and `drop` in milliseconds.
- * Defaults to 0.
- */
- async dragAndDrop(
- start: Point,
- target: Point,
- options: {delay?: number} = {}
- ): Promise<void> {
- const {delay = null} = options;
- const data = await this.drag(start, target);
- await this.dragEnter(target, data);
- await this.dragOver(target, data);
- if (delay) {
- await new Promise((resolve) => {
- return setTimeout(resolve, delay);
- });
- }
-
- await this.drop(target, data);
- await this.up();
- }
-}
-
-/**
- * The Touchscreen class exposes touchscreen events.
- * @public
- */
-export class Touchscreen {
- #client: CDPSession;
- #keyboard: Keyboard;
-
- /**
- * @internal
- */
- constructor(client: CDPSession, keyboard: Keyboard) {
- this.#client = client;
- this.#keyboard = keyboard;
- }
-
- /**
- * Dispatches a `touchstart` and `touchend` event.
- * @param x - Horizontal position of the tap.
- * @param y - Vertical position of the tap.
- */
- async tap(x: number, y: number): Promise<void> {
- const touchPoints = [{x: Math.round(x), y: Math.round(y)}];
- await this.#client.send('Input.dispatchTouchEvent', {
- type: 'touchStart',
- touchPoints,
- modifiers: this.#keyboard._modifiers,
- });
- await this.#client.send('Input.dispatchTouchEvent', {
- type: 'touchEnd',
- touchPoints: [],
- modifiers: this.#keyboard._modifiers,
- });
- }
-}
diff --git a/packages/renderer/src/browser/JSHandle.ts b/packages/renderer/src/browser/JSHandle.ts
index 13ae8172ff..bb1e57aea2 100644
--- a/packages/renderer/src/browser/JSHandle.ts
+++ b/packages/renderer/src/browser/JSHandle.ts
@@ -26,9 +26,7 @@ import {
} from './EvalTypes';
import {ExecutionContext} from './ExecutionContext';
import {Frame, FrameManager} from './FrameManager';
-import {MouseButton} from './Input';
import {Page, ScreenshotOptions} from './Page';
-import {KeyInput} from './USKeyboardLayout';
import {
debugError,
isString,
@@ -685,87 +683,6 @@ export class ElementHandle<
});
}
- /**
- * This method scrolls element into view if needed, and then
- * uses {@link Page.mouse} to hover over the center of the element.
- * If the element is detached from DOM, the method throws an error.
- */
- async hover(): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const {x, y} = await this.clickablePoint();
- await this.#page.mouse.move(x, y);
- }
-
- /**
- * This method scrolls element into view if needed, and then
- * uses {@link Page.mouse} to click in the center of the element.
- * If the element is detached from DOM, the method throws an error.
- */
- async click(options: ClickOptions = {}): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const {x, y} = await this.clickablePoint(options.offset);
- await this.#page.mouse.click(x, y, options);
- }
-
- /**
- * This method creates and captures a dragevent from the element.
- */
- async drag(target: Point): Promise<Protocol.Input.DragData> {
- assert(
- this.#page.isDragInterceptionEnabled(),
- 'Drag Interception is not enabled!'
- );
- await this.#scrollIntoViewIfNeeded();
- const start = await this.clickablePoint();
- return await this.#page.mouse.drag(start, target);
- }
-
- /**
- * This method creates a `dragenter` event on the element.
- */
- async dragEnter(
- data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1}
- ): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const target = await this.clickablePoint();
- await this.#page.mouse.dragEnter(target, data);
- }
-
- /**
- * This method creates a `dragover` event on the element.
- */
- async dragOver(
- data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1}
- ): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const target = await this.clickablePoint();
- await this.#page.mouse.dragOver(target, data);
- }
-
- /**
- * This method triggers a drop on the element.
- */
- async drop(
- data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1}
- ): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const destination = await this.clickablePoint();
- await this.#page.mouse.drop(destination, data);
- }
-
- /**
- * This method triggers a dragenter, dragover, and drop on the element.
- */
- async dragAndDrop(
- target: ElementHandle,
- options?: {delay: number}
- ): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const startPoint = await this.clickablePoint();
- const targetPoint = await target.clickablePoint();
- await this.#page.mouse.dragAndDrop(startPoint, targetPoint, options);
- }
-
/**
* Triggers a `change` and `input` event once all the provided options have been
* selected. If there's no `<select>` element matching `selector`, the method
@@ -900,17 +817,6 @@ export class ElementHandle<
}
}
- /**
- * This method scrolls element into view if needed, and then uses
- * {@link Touchscreen.tap} to tap in the center of the element.
- * If the element is detached from DOM, the method throws an error.
- */
- async tap(): Promise<void> {
- await this.#scrollIntoViewIfNeeded();
- const {x, y} = await this.clickablePoint();
- await this.#page.touchscreen.tap(x, y);
- }
-
/**
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | focus} on the element.
*/
@@ -920,52 +826,6 @@ export class ElementHandle<
});
}
- /**
- * Focuses the element, and then sends a `keydown`, `keypress`/`input`, and
- * `keyup` event for each character in the text.
- *
- * To press a special key, like `Control` or `ArrowDown`,
- * use {@link ElementHandle.press}.
- *
- * @example
- * ```js
- * await elementHandle.type('Hello'); // Types instantly
- * await elementHandle.type('World', {delay: 100}); // Types slower, like a user
- * ```
- *
- * @example
- * An example of typing into a text field and then submitting the form:
- *
- * ```js
- * const elementHandle = await page.$('input');
- * await elementHandle.type('some text');
- * await elementHandle.press('Enter');
- * ```
- */
- async type(text: string, options?: {delay: number}): Promise<void> {
- await this.focus();
- await this.#page.keyboard.type(text, options);
- }
-
- /**
- * Focuses the element, and then uses {@link Keyboard.down} and {@link Keyboard.up}.
- *
- * @remarks
- * If `key` is a single character and no modifier keys besides `Shift`
- * are being held down, a `keypress`/`input` event will also be generated.
- * The `text` option can be specified to force an input event to be generated.
- *
- * **NOTE** Modifier keys DO affect `elementHandle.press`. Holding down `Shift`
- * will type the text in upper case.
- *
- * @param key - Name of key to press, such as `ArrowLeft`.
- * See {@link KeyInput} for a list of all key names.
- */
- async press(key: KeyInput, options?: PressOptions): Promise<void> {
- await this.focus();
- await this.#page.keyboard.press(key, options);
- }
-
/**
* This method returns the bounding box of the element (relative to the main frame),
* or `null` if the element is not visible.
@@ -1158,44 +1018,6 @@ interface Offset {
y: number;
}
-/**
- * @public
- */
-interface ClickOptions {
- /**
- * Time to wait between `mousedown` and `mouseup` in milliseconds.
- *
- * @defaultValue 0
- */
- delay?: number;
- /**
- * @defaultValue 'left'
- */
- button?: MouseButton;
- /**
- * @defaultValue 1
- */
- clickCount?: number;
- /**
- * Offset for the clickable point relative to the top-left corder of the border box.
- */
- offset?: Offset;
-}
-
-/**
- * @public
- */
-interface PressOptions {
- /**
- * Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- */
- delay?: number;
- /**
- * If specified, generates an input event with this text.
- */
- text?: string;
-}
-
/**
* @public
*/
diff --git a/packages/renderer/src/browser/Page.ts b/packages/renderer/src/browser/Page.ts
index 338ba12c5e..96844b0614 100644
--- a/packages/renderer/src/browser/Page.ts
+++ b/packages/renderer/src/browser/Page.ts
@@ -32,7 +32,6 @@ import {FileChooser} from './FileChooser';
import {Frame, FrameManager, FrameManagerEmittedEvents} from './FrameManager';
import {HTTPRequest} from './HTTPRequest';
import {HTTPResponse} from './HTTPResponse';
-import {Keyboard, Mouse, Touchscreen} from './Input';
import {ElementHandle, JSHandle, _createJSHandle} from './JSHandle';
import {PuppeteerLifeCycleEvent} from './LifecycleWatcher';
import {NetworkConditions, NetworkManagerEmittedEvents} from './NetworkManager';
@@ -425,10 +424,7 @@ export class Page extends EventEmitter {
#closed = false;
#client: CDPSession;
#target: Target;
- #keyboard: Keyboard;
- #mouse: Mouse;
#timeoutSettings = new TimeoutSettings();
- #touchscreen: Touchscreen;
#frameManager: FrameManager;
#emulationManager: EmulationManager;
#pageBindings = new Map<string, Function>();
@@ -455,9 +451,6 @@ export class Page extends EventEmitter {
super();
this.#client = client;
this.#target = target;
- this.#keyboard = new Keyboard(client);
- this.#mouse = new Mouse(client, this.#keyboard);
- this.#touchscreen = new Touchscreen(client, this.#keyboard);
this.#frameManager = new FrameManager(
client,
this,
@@ -788,14 +781,6 @@ export class Page extends EventEmitter {
return this.#frameManager.mainFrame();
}
- get keyboard(): Keyboard {
- return this.#keyboard;
- }
-
- get touchscreen(): Touchscreen {
- return this.#touchscreen;
- }
-
/**
* @returns An array of all frames attached to the page.
*/
@@ -2628,10 +2613,6 @@ export class Page extends EventEmitter {
return this.#closed;
}
- get mouse(): Mouse {
- return this.#mouse;
- }
-
/**
* @remarks
*
diff --git a/packages/renderer/src/browser/USKeyboardLayout.ts b/packages/renderer/src/browser/USKeyboardLayout.ts
deleted file mode 100644
index d3a51431d8..0000000000
--- a/packages/renderer/src/browser/USKeyboardLayout.ts
+++ /dev/null
@@ -1,681 +0,0 @@
-/**
- * Copyright 2017 Google Inc. All rights reserved.
- *
- * 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.
- */
-
-/**
- * @internal
- */
-export interface KeyDefinition {
- keyCode?: number;
- shiftKeyCode?: number;
- key?: string;
- shiftKey?: string;
- code?: string;
- text?: string;
- shiftText?: string;
- location?: number;
-}
-
-/**
- * All the valid keys that can be passed to functions that take user input, such
- * as {@link Keyboard.press | keyboard.press }
- *
- * @public
- */
-export type KeyInput =
- | '0'
- | '1'
- | '2'
- | '3'
- | '4'
- | '5'
- | '6'
- | '7'
- | '8'
- | '9'
- | 'Power'
- | 'Eject'
- | 'Abort'
- | 'Help'
- | 'Backspace'
- | 'Tab'
- | 'Numpad5'
- | 'NumpadEnter'
- | 'Enter'
- | '\r'
- | '\n'
- | 'ShiftLeft'
- | 'ShiftRight'
- | 'ControlLeft'
- | 'ControlRight'
- | 'AltLeft'
- | 'AltRight'
- | 'Pause'
- | 'CapsLock'
- | 'Escape'
- | 'Convert'
- | 'NonConvert'
- | 'Space'
- | 'Numpad9'
- | 'PageUp'
- | 'Numpad3'
- | 'PageDown'
- | 'End'
- | 'Numpad1'
- | 'Home'
- | 'Numpad7'
- | 'ArrowLeft'
- | 'Numpad4'
- | 'Numpad8'
- | 'ArrowUp'
- | 'ArrowRight'
- | 'Numpad6'
- | 'Numpad2'
- | 'ArrowDown'
- | 'Select'
- | 'Open'
- | 'PrintScreen'
- | 'Insert'
- | 'Numpad0'
- | 'Delete'
- | 'NumpadDecimal'
- | 'Digit0'
- | 'Digit1'
- | 'Digit2'
- | 'Digit3'
- | 'Digit4'
- | 'Digit5'
- | 'Digit6'
- | 'Digit7'
- | 'Digit8'
- | 'Digit9'
- | 'KeyA'
- | 'KeyB'
- | 'KeyC'
- | 'KeyD'
- | 'KeyE'
- | 'KeyF'
- | 'KeyG'
- | 'KeyH'
- | 'KeyI'
- | 'KeyJ'
- | 'KeyK'
- | 'KeyL'
- | 'KeyM'
- | 'KeyN'
- | 'KeyO'
- | 'KeyP'
- | 'KeyQ'
- | 'KeyR'
- | 'KeyS'
- | 'KeyT'
- | 'KeyU'
- | 'KeyV'
- | 'KeyW'
- | 'KeyX'
- | 'KeyY'
- | 'KeyZ'
- | 'MetaLeft'
- | 'MetaRight'
- | 'ContextMenu'
- | 'NumpadMultiply'
- | 'NumpadAdd'
- | 'NumpadSubtract'
- | 'NumpadDivide'
- | 'F1'
- | 'F2'
- | 'F3'
- | 'F4'
- | 'F5'
- | 'F6'
- | 'F7'
- | 'F8'
- | 'F9'
- | 'F10'
- | 'F11'
- | 'F12'
- | 'F13'
- | 'F14'
- | 'F15'
- | 'F16'
- | 'F17'
- | 'F18'
- | 'F19'
- | 'F20'
- | 'F21'
- | 'F22'
- | 'F23'
- | 'F24'
- | 'NumLock'
- | 'ScrollLock'
- | 'AudioVolumeMute'
- | 'AudioVolumeDown'
- | 'AudioVolumeUp'
- | 'MediaTrackNext'
- | 'MediaTrackPrevious'
- | 'MediaStop'
- | 'MediaPlayPause'
- | 'Semicolon'
- | 'Equal'
- | 'NumpadEqual'
- | 'Comma'
- | 'Minus'
- | 'Period'
- | 'Slash'
- | 'Backquote'
- | 'BracketLeft'
- | 'Backslash'
- | 'BracketRight'
- | 'Quote'
- | 'AltGraph'
- | 'Props'
- | 'Cancel'
- | 'Clear'
- | 'Shift'
- | 'Control'
- | 'Alt'
- | 'Accept'
- | 'ModeChange'
- | ' '
- | 'Print'
- | 'Execute'
- | '\u0000'
- | 'a'
- | 'b'
- | 'c'
- | 'd'
- | 'e'
- | 'f'
- | 'g'
- | 'h'
- | 'i'
- | 'j'
- | 'k'
- | 'l'
- | 'm'
- | 'n'
- | 'o'
- | 'p'
- | 'q'
- | 'r'
- | 's'
- | 't'
- | 'u'
- | 'v'
- | 'w'
- | 'x'
- | 'y'
- | 'z'
- | 'Meta'
- | '*'
- | '+'
- | '-'
- | '/'
- | ';'
- | '='
- | ','
- | '.'
- | '`'
- | '['
- | '\\'
- | ']'
- | "'"
- | 'Attn'
- | 'CrSel'
- | 'ExSel'
- | 'EraseEof'
- | 'Play'
- | 'ZoomOut'
- | ')'
- | '!'
- | '@'
- | '#'
- | '$'
- | '%'
- | '^'
- | '&'
- | '('
- | 'A'
- | 'B'
- | 'C'
- | 'D'
- | 'E'
- | 'F'
- | 'G'
- | 'H'
- | 'I'
- | 'J'
- | 'K'
- | 'L'
- | 'M'
- | 'N'
- | 'O'
- | 'P'
- | 'Q'
- | 'R'
- | 'S'
- | 'T'
- | 'U'
- | 'V'
- | 'W'
- | 'X'
- | 'Y'
- | 'Z'
- | ':'
- | '<'
- | '_'
- | '>'
- | '?'
- | '~'
- | '{'
- | '|'
- | '}'
- | '"'
- | 'SoftLeft'
- | 'SoftRight'
- | 'Camera'
- | 'Call'
- | 'EndCall'
- | 'VolumeDown'
- | 'VolumeUp';
-
-/**
- * @internal
- */
-export const _keyDefinitions: Readonly<Record<KeyInput, KeyDefinition>> = {
- '0': {keyCode: 48, key: '0', code: 'Digit0'},
- '1': {keyCode: 49, key: '1', code: 'Digit1'},
- '2': {keyCode: 50, key: '2', code: 'Digit2'},
- '3': {keyCode: 51, key: '3', code: 'Digit3'},
- '4': {keyCode: 52, key: '4', code: 'Digit4'},
- '5': {keyCode: 53, key: '5', code: 'Digit5'},
- '6': {keyCode: 54, key: '6', code: 'Digit6'},
- '7': {keyCode: 55, key: '7', code: 'Digit7'},
- '8': {keyCode: 56, key: '8', code: 'Digit8'},
- '9': {keyCode: 57, key: '9', code: 'Digit9'},
- Power: {key: 'Power', code: 'Power'},
- Eject: {key: 'Eject', code: 'Eject'},
- Abort: {keyCode: 3, code: 'Abort', key: 'Cancel'},
- Help: {keyCode: 6, code: 'Help', key: 'Help'},
- Backspace: {keyCode: 8, code: 'Backspace', key: 'Backspace'},
- Tab: {keyCode: 9, code: 'Tab', key: 'Tab'},
- Numpad5: {
- keyCode: 12,
- shiftKeyCode: 101,
- key: 'Clear',
- code: 'Numpad5',
- shiftKey: '5',
- location: 3,
- },
- NumpadEnter: {
- keyCode: 13,
- code: 'NumpadEnter',
- key: 'Enter',
- text: '\r',
- location: 3,
- },
- Enter: {keyCode: 13, code: 'Enter', key: 'Enter', text: '\r'},
- '\r': {keyCode: 13, code: 'Enter', key: 'Enter', text: '\r'},
- '\n': {keyCode: 13, code: 'Enter', key: 'Enter', text: '\r'},
- ShiftLeft: {keyCode: 16, code: 'ShiftLeft', key: 'Shift', location: 1},
- ShiftRight: {keyCode: 16, code: 'ShiftRight', key: 'Shift', location: 2},
- ControlLeft: {
- keyCode: 17,
- code: 'ControlLeft',
- key: 'Control',
- location: 1,
- },
- ControlRight: {
- keyCode: 17,
- code: 'ControlRight',
- key: 'Control',
- location: 2,
- },
- AltLeft: {keyCode: 18, code: 'AltLeft', key: 'Alt', location: 1},
- AltRight: {keyCode: 18, code: 'AltRight', key: 'Alt', location: 2},
- Pause: {keyCode: 19, code: 'Pause', key: 'Pause'},
- CapsLock: {keyCode: 20, code: 'CapsLock', key: 'CapsLock'},
- Escape: {keyCode: 27, code: 'Escape', key: 'Escape'},
- Convert: {keyCode: 28, code: 'Convert', key: 'Convert'},
- NonConvert: {keyCode: 29, code: 'NonConvert', key: 'NonConvert'},
- Space: {keyCode: 32, code: 'Space', key: ' '},
- Numpad9: {
- keyCode: 33,
- shiftKeyCode: 105,
- key: 'PageUp',
- code: 'Numpad9',
- shiftKey: '9',
- location: 3,
- },
- PageUp: {keyCode: 33, code: 'PageUp', key: 'PageUp'},
- Numpad3: {
- keyCode: 34,
- shiftKeyCode: 99,
- key: 'PageDown',
- code: 'Numpad3',
- shiftKey: '3',
- location: 3,
- },
- PageDown: {keyCode: 34, code: 'PageDown', key: 'PageDown'},
- End: {keyCode: 35, code: 'End', key: 'End'},
- Numpad1: {
- keyCode: 35,
- shiftKeyCode: 97,
- key: 'End',
- code: 'Numpad1',
- shiftKey: '1',
- location: 3,
- },
- Home: {keyCode: 36, code: 'Home', key: 'Home'},
- Numpad7: {
- keyCode: 36,
- shiftKeyCode: 103,
- key: 'Home',
- code: 'Numpad7',
- shiftKey: '7',
- location: 3,
- },
- ArrowLeft: {keyCode: 37, code: 'ArrowLeft', key: 'ArrowLeft'},
- Numpad4: {
- keyCode: 37,
- shiftKeyCode: 100,
- key: 'ArrowLeft',
- code: 'Numpad4',
- shiftKey: '4',
- location: 3,
- },
- Numpad8: {
- keyCode: 38,
- shiftKeyCode: 104,
- key: 'ArrowUp',
- code: 'Numpad8',
- shiftKey: '8',
- location: 3,
- },
- ArrowUp: {keyCode: 38, code: 'ArrowUp', key: 'ArrowUp'},
- ArrowRight: {keyCode: 39, code: 'ArrowRight', key: 'ArrowRight'},
- Numpad6: {
- keyCode: 39,
- shiftKeyCode: 102,
- key: 'ArrowRight',
- code: 'Numpad6',
- shiftKey: '6',
- location: 3,
- },
- Numpad2: {
- keyCode: 40,
- shiftKeyCode: 98,
- key: 'ArrowDown',
- code: 'Numpad2',
- shiftKey: '2',
- location: 3,
- },
- ArrowDown: {keyCode: 40, code: 'ArrowDown', key: 'ArrowDown'},
- Select: {keyCode: 41, code: 'Select', key: 'Select'},
- Open: {keyCode: 43, code: 'Open', key: 'Execute'},
- PrintScreen: {keyCode: 44, code: 'PrintScreen', key: 'PrintScreen'},
- Insert: {keyCode: 45, code: 'Insert', key: 'Insert'},
- Numpad0: {
- keyCode: 45,
- shiftKeyCode: 96,
- key: 'Insert',
- code: 'Numpad0',
- shiftKey: '0',
- location: 3,
- },
- Delete: {keyCode: 46, code: 'Delete', key: 'Delete'},
- NumpadDecimal: {
- keyCode: 46,
- shiftKeyCode: 110,
- code: 'NumpadDecimal',
- key: '\u0000',
- shiftKey: '.',
- location: 3,
- },
- Digit0: {keyCode: 48, code: 'Digit0', shiftKey: ')', key: '0'},
- Digit1: {keyCode: 49, code: 'Digit1', shiftKey: '!', key: '1'},
- Digit2: {keyCode: 50, code: 'Digit2', shiftKey: '@', key: '2'},
- Digit3: {keyCode: 51, code: 'Digit3', shiftKey: '#', key: '3'},
- Digit4: {keyCode: 52, code: 'Digit4', shiftKey: '$', key: '4'},
- Digit5: {keyCode: 53, code: 'Digit5', shiftKey: '%', key: '5'},
- Digit6: {keyCode: 54, code: 'Digit6', shiftKey: '^', key: '6'},
- Digit7: {keyCode: 55, code: 'Digit7', shiftKey: '&', key: '7'},
- Digit8: {keyCode: 56, code: 'Digit8', shiftKey: '*', key: '8'},
- Digit9: {keyCode: 57, code: 'Digit9', shiftKey: '(', key: '9'},
- KeyA: {keyCode: 65, code: 'KeyA', shiftKey: 'A', key: 'a'},
- KeyB: {keyCode: 66, code: 'KeyB', shiftKey: 'B', key: 'b'},
- KeyC: {keyCode: 67, code: 'KeyC', shiftKey: 'C', key: 'c'},
- KeyD: {keyCode: 68, code: 'KeyD', shiftKey: 'D', key: 'd'},
- KeyE: {keyCode: 69, code: 'KeyE', shiftKey: 'E', key: 'e'},
- KeyF: {keyCode: 70, code: 'KeyF', shiftKey: 'F', key: 'f'},
- KeyG: {keyCode: 71, code: 'KeyG', shiftKey: 'G', key: 'g'},
- KeyH: {keyCode: 72, code: 'KeyH', shiftKey: 'H', key: 'h'},
- KeyI: {keyCode: 73, code: 'KeyI', shiftKey: 'I', key: 'i'},
- KeyJ: {keyCode: 74, code: 'KeyJ', shiftKey: 'J', key: 'j'},
- KeyK: {keyCode: 75, code: 'KeyK', shiftKey: 'K', key: 'k'},
- KeyL: {keyCode: 76, code: 'KeyL', shiftKey: 'L', key: 'l'},
- KeyM: {keyCode: 77, code: 'KeyM', shiftKey: 'M', key: 'm'},
- KeyN: {keyCode: 78, code: 'KeyN', shiftKey: 'N', key: 'n'},
- KeyO: {keyCode: 79, code: 'KeyO', shiftKey: 'O', key: 'o'},
- KeyP: {keyCode: 80, code: 'KeyP', shiftKey: 'P', key: 'p'},
- KeyQ: {keyCode: 81, code: 'KeyQ', shiftKey: 'Q', key: 'q'},
- KeyR: {keyCode: 82, code: 'KeyR', shiftKey: 'R', key: 'r'},
- KeyS: {keyCode: 83, code: 'KeyS', shiftKey: 'S', key: 's'},
- KeyT: {keyCode: 84, code: 'KeyT', shiftKey: 'T', key: 't'},
- KeyU: {keyCode: 85, code: 'KeyU', shiftKey: 'U', key: 'u'},
- KeyV: {keyCode: 86, code: 'KeyV', shiftKey: 'V', key: 'v'},
- KeyW: {keyCode: 87, code: 'KeyW', shiftKey: 'W', key: 'w'},
- KeyX: {keyCode: 88, code: 'KeyX', shiftKey: 'X', key: 'x'},
- KeyY: {keyCode: 89, code: 'KeyY', shiftKey: 'Y', key: 'y'},
- KeyZ: {keyCode: 90, code: 'KeyZ', shiftKey: 'Z', key: 'z'},
- MetaLeft: {keyCode: 91, code: 'MetaLeft', key: 'Meta', location: 1},
- MetaRight: {keyCode: 92, code: 'MetaRight', key: 'Meta', location: 2},
- ContextMenu: {keyCode: 93, code: 'ContextMenu', key: 'ContextMenu'},
- NumpadMultiply: {
- keyCode: 106,
- code: 'NumpadMultiply',
- key: '*',
- location: 3,
- },
- NumpadAdd: {keyCode: 107, code: 'NumpadAdd', key: '+', location: 3},
- NumpadSubtract: {
- keyCode: 109,
- code: 'NumpadSubtract',
- key: '-',
- location: 3,
- },
- NumpadDivide: {keyCode: 111, code: 'NumpadDivide', key: '/', location: 3},
- F1: {keyCode: 112, code: 'F1', key: 'F1'},
- F2: {keyCode: 113, code: 'F2', key: 'F2'},
- F3: {keyCode: 114, code: 'F3', key: 'F3'},
- F4: {keyCode: 115, code: 'F4', key: 'F4'},
- F5: {keyCode: 116, code: 'F5', key: 'F5'},
- F6: {keyCode: 117, code: 'F6', key: 'F6'},
- F7: {keyCode: 118, code: 'F7', key: 'F7'},
- F8: {keyCode: 119, code: 'F8', key: 'F8'},
- F9: {keyCode: 120, code: 'F9', key: 'F9'},
- F10: {keyCode: 121, code: 'F10', key: 'F10'},
- F11: {keyCode: 122, code: 'F11', key: 'F11'},
- F12: {keyCode: 123, code: 'F12', key: 'F12'},
- F13: {keyCode: 124, code: 'F13', key: 'F13'},
- F14: {keyCode: 125, code: 'F14', key: 'F14'},
- F15: {keyCode: 126, code: 'F15', key: 'F15'},
- F16: {keyCode: 127, code: 'F16', key: 'F16'},
- F17: {keyCode: 128, code: 'F17', key: 'F17'},
- F18: {keyCode: 129, code: 'F18', key: 'F18'},
- F19: {keyCode: 130, code: 'F19', key: 'F19'},
- F20: {keyCode: 131, code: 'F20', key: 'F20'},
- F21: {keyCode: 132, code: 'F21', key: 'F21'},
- F22: {keyCode: 133, code: 'F22', key: 'F22'},
- F23: {keyCode: 134, code: 'F23', key: 'F23'},
- F24: {keyCode: 135, code: 'F24', key: 'F24'},
- NumLock: {keyCode: 144, code: 'NumLock', key: 'NumLock'},
- ScrollLock: {keyCode: 145, code: 'ScrollLock', key: 'ScrollLock'},
- AudioVolumeMute: {
- keyCode: 173,
- code: 'AudioVolumeMute',
- key: 'AudioVolumeMute',
- },
- AudioVolumeDown: {
- keyCode: 174,
- code: 'AudioVolumeDown',
- key: 'AudioVolumeDown',
- },
- AudioVolumeUp: {keyCode: 175, code: 'AudioVolumeUp', key: 'AudioVolumeUp'},
- MediaTrackNext: {
- keyCode: 176,
- code: 'MediaTrackNext',
- key: 'MediaTrackNext',
- },
- MediaTrackPrevious: {
- keyCode: 177,
- code: 'MediaTrackPrevious',
- key: 'MediaTrackPrevious',
- },
- MediaStop: {keyCode: 178, code: 'MediaStop', key: 'MediaStop'},
- MediaPlayPause: {
- keyCode: 179,
- code: 'MediaPlayPause',
- key: 'MediaPlayPause',
- },
- Semicolon: {keyCode: 186, code: 'Semicolon', shiftKey: ':', key: ';'},
- Equal: {keyCode: 187, code: 'Equal', shiftKey: '+', key: '='},
- NumpadEqual: {keyCode: 187, code: 'NumpadEqual', key: '=', location: 3},
- Comma: {keyCode: 188, code: 'Comma', shiftKey: '<', key: ','},
- Minus: {keyCode: 189, code: 'Minus', shiftKey: '_', key: '-'},
- Period: {keyCode: 190, code: 'Period', shiftKey: '>', key: '.'},
- Slash: {keyCode: 191, code: 'Slash', shiftKey: '?', key: '/'},
- Backquote: {keyCode: 192, code: 'Backquote', shiftKey: '~', key: '`'},
- BracketLeft: {keyCode: 219, code: 'BracketLeft', shiftKey: '{', key: '['},
- Backslash: {keyCode: 220, code: 'Backslash', shiftKey: '|', key: '\\'},
- BracketRight: {keyCode: 221, code: 'BracketRight', shiftKey: '}', key: ']'},
- Quote: {keyCode: 222, code: 'Quote', shiftKey: '"', key: "'"},
- AltGraph: {keyCode: 225, code: 'AltGraph', key: 'AltGraph'},
- Props: {keyCode: 247, code: 'Props', key: 'CrSel'},
- Cancel: {keyCode: 3, key: 'Cancel', code: 'Abort'},
- Clear: {keyCode: 12, key: 'Clear', code: 'Numpad5', location: 3},
- Shift: {keyCode: 16, key: 'Shift', code: 'ShiftLeft', location: 1},
- Control: {keyCode: 17, key: 'Control', code: 'ControlLeft', location: 1},
- Alt: {keyCode: 18, key: 'Alt', code: 'AltLeft', location: 1},
- Accept: {keyCode: 30, key: 'Accept'},
- ModeChange: {keyCode: 31, key: 'ModeChange'},
- ' ': {keyCode: 32, key: ' ', code: 'Space'},
- Print: {keyCode: 42, key: 'Print'},
- Execute: {keyCode: 43, key: 'Execute', code: 'Open'},
- '\u0000': {keyCode: 46, key: '\u0000', code: 'NumpadDecimal', location: 3},
- a: {keyCode: 65, key: 'a', code: 'KeyA'},
- b: {keyCode: 66, key: 'b', code: 'KeyB'},
- c: {keyCode: 67, key: 'c', code: 'KeyC'},
- d: {keyCode: 68, key: 'd', code: 'KeyD'},
- e: {keyCode: 69, key: 'e', code: 'KeyE'},
- f: {keyCode: 70, key: 'f', code: 'KeyF'},
- g: {keyCode: 71, key: 'g', code: 'KeyG'},
- h: {keyCode: 72, key: 'h', code: 'KeyH'},
- i: {keyCode: 73, key: 'i', code: 'KeyI'},
- j: {keyCode: 74, key: 'j', code: 'KeyJ'},
- k: {keyCode: 75, key: 'k', code: 'KeyK'},
- l: {keyCode: 76, key: 'l', code: 'KeyL'},
- m: {keyCode: 77, key: 'm', code: 'KeyM'},
- n: {keyCode: 78, key: 'n', code: 'KeyN'},
- o: {keyCode: 79, key: 'o', code: 'KeyO'},
- p: {keyCode: 80, key: 'p', code: 'KeyP'},
- q: {keyCode: 81, key: 'q', code: 'KeyQ'},
- r: {keyCode: 82, key: 'r', code: 'KeyR'},
- s: {keyCode: 83, key: 's', code: 'KeyS'},
- t: {keyCode: 84, key: 't', code: 'KeyT'},
- u: {keyCode: 85, key: 'u', code: 'KeyU'},
- v: {keyCode: 86, key: 'v', code: 'KeyV'},
- w: {keyCode: 87, key: 'w', code: 'KeyW'},
- x: {keyCode: 88, key: 'x', code: 'KeyX'},
- y: {keyCode: 89, key: 'y', code: 'KeyY'},
- z: {keyCode: 90, key: 'z', code: 'KeyZ'},
- Meta: {keyCode: 91, key: 'Meta', code: 'MetaLeft', location: 1},
- '*': {keyCode: 106, key: '*', code: 'NumpadMultiply', location: 3},
- '+': {keyCode: 107, key: '+', code: 'NumpadAdd', location: 3},
- '-': {keyCode: 109, key: '-', code: 'NumpadSubtract', location: 3},
- '/': {keyCode: 111, key: '/', code: 'NumpadDivide', location: 3},
- ';': {keyCode: 186, key: ';', code: 'Semicolon'},
- '=': {keyCode: 187, key: '=', code: 'Equal'},
- ',': {keyCode: 188, key: ',', code: 'Comma'},
- '.': {keyCode: 190, key: '.', code: 'Period'},
- '`': {keyCode: 192, key: '`', code: 'Backquote'},
- '[': {keyCode: 219, key: '[', code: 'BracketLeft'},
- '\\': {keyCode: 220, key: '\\', code: 'Backslash'},
- ']': {keyCode: 221, key: ']', code: 'BracketRight'},
- "'": {keyCode: 222, key: "'", code: 'Quote'},
- Attn: {keyCode: 246, key: 'Attn'},
- CrSel: {keyCode: 247, key: 'CrSel', code: 'Props'},
- ExSel: {keyCode: 248, key: 'ExSel'},
- EraseEof: {keyCode: 249, key: 'EraseEof'},
- Play: {keyCode: 250, key: 'Play'},
- ZoomOut: {keyCode: 251, key: 'ZoomOut'},
- ')': {keyCode: 48, key: ')', code: 'Digit0'},
- '!': {keyCode: 49, key: '!', code: 'Digit1'},
- '@': {keyCode: 50, key: '@', code: 'Digit2'},
- '#': {keyCode: 51, key: '#', code: 'Digit3'},
- $: {keyCode: 52, key: '$', code: 'Digit4'},
- '%': {keyCode: 53, key: '%', code: 'Digit5'},
- '^': {keyCode: 54, key: '^', code: 'Digit6'},
- '&': {keyCode: 55, key: '&', code: 'Digit7'},
- '(': {keyCode: 57, key: '(', code: 'Digit9'},
- A: {keyCode: 65, key: 'A', code: 'KeyA'},
- B: {keyCode: 66, key: 'B', code: 'KeyB'},
- C: {keyCode: 67, key: 'C', code: 'KeyC'},
- D: {keyCode: 68, key: 'D', code: 'KeyD'},
- E: {keyCode: 69, key: 'E', code: 'KeyE'},
- F: {keyCode: 70, key: 'F', code: 'KeyF'},
- G: {keyCode: 71, key: 'G', code: 'KeyG'},
- H: {keyCode: 72, key: 'H', code: 'KeyH'},
- I: {keyCode: 73, key: 'I', code: 'KeyI'},
- J: {keyCode: 74, key: 'J', code: 'KeyJ'},
- K: {keyCode: 75, key: 'K', code: 'KeyK'},
- L: {keyCode: 76, key: 'L', code: 'KeyL'},
- M: {keyCode: 77, key: 'M', code: 'KeyM'},
- N: {keyCode: 78, key: 'N', code: 'KeyN'},
- O: {keyCode: 79, key: 'O', code: 'KeyO'},
- P: {keyCode: 80, key: 'P', code: 'KeyP'},
- Q: {keyCode: 81, key: 'Q', code: 'KeyQ'},
- R: {keyCode: 82, key: 'R', code: 'KeyR'},
- S: {keyCode: 83, key: 'S', code: 'KeyS'},
- T: {keyCode: 84, key: 'T', code: 'KeyT'},
- U: {keyCode: 85, key: 'U', code: 'KeyU'},
- V: {keyCode: 86, key: 'V', code: 'KeyV'},
- W: {keyCode: 87, key: 'W', code: 'KeyW'},
- X: {keyCode: 88, key: 'X', code: 'KeyX'},
- Y: {keyCode: 89, key: 'Y', code: 'KeyY'},
- Z: {keyCode: 90, key: 'Z', code: 'KeyZ'},
- ':': {keyCode: 186, key: ':', code: 'Semicolon'},
- '<': {keyCode: 188, key: '<', code: 'Comma'},
- _: {keyCode: 189, key: '_', code: 'Minus'},
- '>': {keyCode: 190, key: '>', code: 'Period'},
- '?': {keyCode: 191, key: '?', code: 'Slash'},
- '~': {keyCode: 192, key: '~', code: 'Backquote'},
- '{': {keyCode: 219, key: '{', code: 'BracketLeft'},
- '|': {keyCode: 220, key: '|', code: 'Backslash'},
- '}': {keyCode: 221, key: '}', code: 'BracketRight'},
- '"': {keyCode: 222, key: '"', code: 'Quote'},
- SoftLeft: {key: 'SoftLeft', code: 'SoftLeft', location: 4},
- SoftRight: {key: 'SoftRight', code: 'SoftRight', location: 4},
- Camera: {keyCode: 44, key: 'Camera', code: 'Camera', location: 4},
- Call: {key: 'Call', code: 'Call', location: 4},
- EndCall: {keyCode: 95, key: 'EndCall', code: 'EndCall', location: 4},
- VolumeDown: {
- keyCode: 182,
- key: 'VolumeDown',
- code: 'VolumeDown',
- location: 4,
- },
- VolumeUp: {keyCode: 183, key: 'VolumeUp', code: 'VolumeUp', location: 4},
-};