ScreenshotNeo

BlogGuides

Puppeteer Keyboard Type Options Explained

Puppeteer’s keyboard.type() accepts one option: delay, measured in milliseconds. Learn what it changes, what it does not, and when to use other keyboard methods.

By the ScreenshotNeo team4 October 20266 min read

page.keyboard.type(text, options) accepts one documented option: delay, the number of milliseconds to wait between key events for each character. It defaults to 0. Use it to control typing timing; it does not change the supplied text or select a different key.

This guide follows the Puppeteer 25.9.0 Keyboard.type() method reference. The Page.type() reference is labeled 25.10.0 and also documents delay with a default of 0.

1. The documented option: delay

Option Type Default Effect
delay number 0 milliseconds Waits between keydown and keyup for each character typed.

With the default, Puppeteer types without an added delay. A positive delay inserts a wait as it types. Puppeteer’s documented example is:

await page.keyboard.type('Hello'); // Types instantly
await page.keyboard.type('World', { delay: 100 }); // Types slower

The value 100 is an API example, not a recommended setting or a claim about typical human typing. A delay controls timing only. It does not transform the string, change which characters are sent, or make automation reliably resemble a person.

2. Complete runnable example

This Node.js example launches Chromium, opens a page with an input, types into it with and without a delay, prints the resulting value, and closes the browser. Install Puppeteer first with npm install puppeteer.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage();
    await page.setContent('<input id="name">');

    await page.focus('#name');
    await page.keyboard.type('Ada');

    await page.focus('#name');
    await page.$eval('#name', input => { input.value = ''; });
    await page.keyboard.type('Lovelace', { delay: 100 });

    const value = await page.$eval('#name', input => input.value);
    console.log(value); // Lovelace
  } finally {
    await browser.close();
  }
})();

The target must be focused before calling page.keyboard.type(); the keyboard API sends input to the page’s currently focused element. For a selector-oriented alternative, Puppeteer also documents page.type(selector, text, options), which accepts the same KeyboardTypeOptions.

3. What type() does and does not do

Keyboard.type() is the high-level API for raw characters. Puppeteer documents it as generating keydown, keypress/input, and keyup events for the characters on the page. That event behavior is useful when the page responds to keyboard input, rather than only to a direct assignment to an element’s value.

  • Raw text: use type('hello') to type characters from a string.
  • Special keys: use press('Enter'), press('ArrowDown'), or another named key for a key action.
  • Modifiers: holding Shift does not make type('hello') produce HELLO. Modifiers affect press() and down(), not type().
  • Manual event control: use down() and up() to control keydown and keyup yourself.
  • Character input without key events: use sendCharacter(); it dispatches character input without keydown or keyup.

The Keyboard class reference describes these method distinctions. Choose the method based on the input and events the page needs, rather than assuming that every keyboard method has the same modifier or event behavior.

4. Choosing a keyboard method

Method Use it for Events and modifiers
type(text, options?) Typing raw characters Character typing events; modifiers do not affect the supplied text. Supports the documented delay option.
press(key) Pressing a named key, including special keys Modifiers can affect the press. Use this for keys such as Control or ArrowDown.
down(key) and up(key) Manually controlling a key press and release Modifiers can affect these actions; the caller controls when each occurs.
sendCharacter(char) Dispatching character input without keydown or keyup Modifiers do not affect it.

For example, type text and then press Enter as a separate operation:

await page.focus('#search');
await page.keyboard.type('puppeteer keyboard');
await page.keyboard.press('Enter');

Do not use type() to represent holding a modifier or pressing a navigation key. Its input is raw characters, not a sequence of named key commands.

5. Selector-based typing with Page.type()

If you want Puppeteer to target an element by selector, page.type() takes the selector, text, and the same type options. The method reference documents delay and a default of 0.

await page.setContent('<input id="email">');
await page.type('#email', 'dev@example.com', { delay: 25 });

For an input that needs to be cleared first, focus it and use the platform’s select-all shortcut followed by Backspace, or use an element operation appropriate to your test. Keep in mind that assigning input.value directly does not generate the same keyboard event sequence as typing.

6. Troubleshooting

Symptom Likely cause Fix
Text appears in the wrong field or nowhere The intended element is not focused. Focus the field first with page.focus(selector), or use the selector-based page.type().
Shift does not capitalize text passed to type() Modifiers do not affect Keyboard.type(). Pass the desired uppercase characters in the string, or use key operations when the test specifically needs modifier behavior.
ArrowDown or Control is not entered as expected These are key actions, not ordinary text characters. Use page.keyboard.press('ArrowDown') or another named key with press().
Page logic does not react to a directly assigned value Setting an element’s value is not the same as typing and generating keyboard events. Use type() when the page needs keyboard input events; use direct assignment only when that is appropriate for the task.
Typing takes longer than expected A positive per-character delay adds time across the string. Remove delay or reduce it when timing is unnecessary. Keep a delay only when the test needs it.
Typing-option example does not match installed docs The cited method references show different version labels: Keyboard.type() is 25.9.0; Page.type() is 25.10.0. Check the documentation for the Puppeteer version installed in the project and use the method supported by that version.

7. Timing, reliability, and test design

Use the default zero delay for ordinary automation when the page only needs the resulting text and keyboard event sequence. Add a delay when elapsed time between key events is part of what the test exercises. Since the delay applies as characters are typed, it adds work as the string grows; avoid adding it to every test without a reason.

A delay does not guarantee that a site will accept input, that a field is ready, or that automation will be classified in any particular way. For reliability, wait for the relevant field or page state, focus the correct input, and assert the result your test expects. The reviewed API references do not establish cross-browser timing benchmarks or behavior differences between environments.

8. Or skip the browser setup

If the goal is to capture how a page looks after it loads, a screenshot API can avoid installing and managing a browser. ScreenshotNeo is a website screenshot API and MCP server; its one-call request returns an image or PDF. Its request parameters include options used by other screenshot APIs, which can ease a switch.

For the DIY browser path, Puppeteer’s Keyboard.type() controls text input and its timing. For a rendered-page capture, ScreenshotNeo can return the result directly:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed; the response identifies the page verdict and billing status. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Create a free ScreenshotNeo account to start with 1,000 screenshots per month and no card.

9. FAQ

Does Keyboard.type() have a speed or interval option besides delay?

The reviewed method reference documents delay as the option in KeyboardTypeOptions. It does not list another typing option.

Can I use delay as a fixed pause before typing starts?

The documented description is a wait between keydown and keyup for each character, not a separate initial pause. Use an explicit wait if the task requires waiting before typing.

Does Page.type() use the same options?

Yes. Its reviewed reference also documents KeyboardTypeOptions, including delay with a default of zero.