How to emulate keyboard input in Puppeteer

To emulate the user typing something on the keyboard, use

puppeteer_emulate_keyboard_input.js
await page.keyboard.type("the text");

This will type the text extremely fast with virtually no delay between the characters.

In order to simulate the finite typing speed of real users, use

example.js
await page.keyboard.type("the text", {delay: 100});

instead. The delay betwen characters in this example is 100 Milliseconds, i.e. the emulated user types 10 characters per second.


Check out similar posts by category: Javascript, NodeJS, Puppeteer