import { Keyboard } from "https://deno.land/x/puppeteer@14.1.1/vendor/puppeteer-core/puppeteer/common/Input.js";
Keyboard provides an api for managing a virtual keyboard. The high level api is Keyboard."type", which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
Examples
An example of holding down Shift
in order to select and delete some text:
An example of holding down Shift
in order to select and delete some text:
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!'
Constructors
new
Keyboard(client: CDPSession)Methods
sendCharacter(char: string): Promise<void>
Dispatches a keypress
and input
event.
This does not send a keydown
or keyup
event.
type(text: string, options?: { delay?: number; }): Promise<void>
Sends a keydown
, keypress
/input
,
and keyup
event for each character in the text.