# Type like a human in Playwright

> To type like a human in Playwright, skip fill() and send keys one at a time with uneven gaps, longer pauses after punctuation and the odd corrected typo.

Source: https://mosaicbrowser.com/guides/type-like-a-human-in-playwright

## How to type like a human in Playwright

To type like a human in Playwright, do not use fill(), which sets the value in one input event, and do not rely on pressSequentially's fixed delay. Send one key at a time with right-skewed gaps, longer pauses after spaces and punctuation, an occasional thinking pause, and now and then a wrong key followed by Backspace.

![320: Characters a minute, Mosaic's default typing speed](https://mosaicbrowser.com/covers/type-like-a-human-in-playwright.webp)

Playwright gives you two ways to put text in a field, and neither is how a person types. `fill()` sets the value. `pressSequentially()` presses keys, with a gap you choose, which is the same gap for every key. Typing like a human means writing the timing yourself, and the timing is the part sites that score behaviour actually read.

## What fill() and pressSequentially() send

Playwright's input guide says `locator.fill()` "focuses the element and triggers an input event with the entered text" ([Playwright docs](https://playwright.dev/docs/input), read 2 November 2026). One event, no keys. A field that goes from empty to a full email address with no `keydown` in front of it is among the cheapest automation signals a page can collect, and a paste looks almost the same: one event, marked `insertFromPaste`, and no key presses at all.

`pressSequentially()` is closer. Its reference says it "sends a `keydown`, `keypress`/`input`, and `keyup` event for each character", and its `delay` option is the "time to wait between key presses in milliseconds", defaulting to 0 ([Locator docs](https://playwright.dev/docs/api/class-locator), read 2 November 2026). The example in the docs is `{ delay: 100 }`, labelled "Types slower, like a user". Slower, yes. But a person typing "hello, world" does not leave 100 ms between every pair of keys.

## What human typing looks like

The intervals between a person's keystrokes are right-skewed: most are quick, a few are much slower, and there is no ceiling. Some patterns are steady enough to model:

- A longer gap after a space or punctuation, where people hesitate.
- A longer gap for a shifted character, which costs an extra key.
- Now and then a pause many times the average, as if reading.
- Now and then a wrong neighbouring key, a beat while the typist notices, then Backspace and the right one.

None of this needs to be clever. It needs to not be constant.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: REST API](https://mosaicbrowser.com/features/rest-api)

## How to type like a human in Playwright

This helper does all four with `page.keyboard`, one key at a time. It assumes the field is already focused.

```
const NEAR = { a: 'qwsz', e: 'wsdr', i: 'ujko', o: 'iklp', n: 'bhjm', s: 'awedxz', t: 'rfgy' }
const sleep = (ms) => new Promise((r) => setTimeout(r, ms))

// Right-skewed: mostly near the mean, occasionally much longer.
function gap(mean) {
  const z = Math.sqrt(-2 * Math.log(1 - Math.random())) * Math.cos(2 * Math.PI * Math.random())
  return mean * Math.exp(0.4 * z - 0.08)
}

export async function typeLikeAPerson(page, text, { cpm = 320, typoRate = 0.015 } = {}) {
  const mean = 60000 / cpm
  for (const ch of text) {
    const near = NEAR[ch.toLowerCase()]
    if (near && Math.random() < typoRate) {
      await page.keyboard.type(near[Math.floor(Math.random() * near.length)])
      await sleep(mean * (1.5 + Math.random() * 2.5))   // the beat before you notice
      await page.keyboard.press('Backspace')
      await sleep(mean * (0.8 + Math.random()))
    }
    if (ch === '\n') await page.keyboard.press('Enter')
    else await page.keyboard.type(ch)

    let wait = gap(mean)
    if (/[\s.,!?;:]/.test(ch)) wait *= 1.6
    if (ch !== ch.toLowerCase()) wait *= 1.3
    if (Math.random() < 0.02) wait += mean * (8 + Math.random() * 12)
    await sleep(wait)
  }
}

```

Call it after clicking into the field: `await page.getByLabel('Email').click()`, then `await typeLikeAPerson(page, 'name@example.com')`. Pick `cpm` per account and keep it, because one person types at roughly one speed.

The keys still go in through the DevTools Input domain, so the page sees them as trusted. On our own engine, `Input.dispatchKeyEvent` left deviceandbrowserinfo's verdict at `isBot=false`. What did flip it to `isBot=true` was `Runtime.enable`, a command Playwright relies on, as [rebrowser's write-up](https://github.com/rebrowser/rebrowser-patches) of the leak explains (read 2 November 2026); the [Playwright guide](https://mosaicbrowser.com/guides/use-playwright-with-an-anti-detect-browser) covers what to do about that.

## Check it on a page you control

Measure your typing before a site does. Open a local page with one input, record when each `keydown` arrives, and print the gaps after the script runs:

```
await page.setContent('<input id="f">')
await page.evaluate(() => {
  window.gaps = []
  let last = 0
  document.getElementById('f').addEventListener('keydown', (e) => {
    const now = performance.now()
    if (last) window.gaps.push(Math.round(now - last))
    last = now
  })
})
await page.click('#f')
await typeLikeAPerson(page, 'Meet me at 10, near the station.')
console.log(await page.evaluate(() => window.gaps))

```

Run it against `pressSequentially('…', { delay: 100 })` as well. That list comes back as a column of near-identical numbers. The helper's list should wander: a run of quick gaps, a slow one after the comma, a long one somewhere for no reason, and two extra entries where a typo went in and came out. If yours has no long tail, raise the spread in `gap()`.

Do this on a page of your own, in a throwaway browser. `page.evaluate` runs script in the page's own world, which a site could notice, and it has no place in the profile you are protecting.

## The same thing without writing it, in Mosaic

Mosaic's typing is the model above, built in. Its routes on the [local REST API](https://mosaicbrowser.com/features/rest-api) need a running profile and an API key.

- `POST /profiles/:id/page/type` types into a field by `ref` or `selector`, clicking it first with a pointer that travels there. With `"clear": true` it selects the existing value with a triple click, so the new text replaces it.
- `POST /profiles/:id/type` types into whatever has focus. Its options are `charactersPerMinute` (default 320), `typoRate` (default 0.015, up to 0.1) and `thinkingPauses` (default on).
- `POST /running/type` types the same text into many running profiles at once, and each window draws its own timing. Forty sessions typing one password at identical intervals would be a pattern of their own.

![Six Mosaic profiles selected, with the bulk bar to start, stop and edit them together](https://mosaicbrowser.com/shots/bulk-actions.png)
*Typing into many profiles starts from a selection like this*

You can mix the two: drive navigation with Playwright and call the typing route for the field that matters, because Chrome accepts more than one DevTools client at a time ([connecting to Chrome over CDP](https://mosaicbrowser.com/guides/connect-to-an-existing-chrome-with-cdp) has the source). The [guide to automating several profiles](https://mosaicbrowser.com/guides/automate-multiple-browser-profiles) shows where typing fits in a batch run. The REST API is part of Pro, $25 a month, charged at checkout, on the [pricing page](https://mosaicbrowser.com/pricing).

## Sources

1. [Playwright docs: Input (text input)](https://playwright.dev/docs/input), read November 2, 2026
2. [Playwright docs: Locator.pressSequentially](https://playwright.dev/docs/api/class-locator), read November 2, 2026
3. [rebrowser-patches: Runtime.Enable leak (GitHub)](https://github.com/rebrowser/rebrowser-patches), read November 2, 2026

## Questions

### Is pressSequentially with a delay enough?

It sends real key events, which fill() does not, but the delay is one fixed number of milliseconds between every key. A field typed at exactly 100 ms per key, every time, is as regular as a machine.

### Are Playwright's key events trusted?

Playwright sends keys through the DevTools Input domain, so the page receives them with isTrusted set to true. On our engine, Input.dispatchKeyEvent did not change deviceandbrowserinfo's bot verdict; enabling the Runtime domain did.

### What typing speed should I use?

Mosaic's typing routes default to 320 characters a minute and treat 200 to 400 as ordinary. Vary it per profile so every account does not type at the same speed.

### Should I add typos to a password field?

A corrected typo is what people do, and the backspace leaves the final value right. Keep the rate low: Mosaic's default is 1.5% of characters, and its typing routes accept up to 10%.

## Related

[How to use Playwright with an anti-detect browser](https://mosaicbrowser.com/guides/use-playwright-with-an-anti-detect-browser): Use Playwright with an anti-detect browser by starting the profile first and attaching with connectOverCDP. Keep its context; leave the fingerprint alone.

[How to automate multiple browser profiles](https://mosaicbrowser.com/guides/automate-multiple-browser-profiles): Automate multiple browser profiles by giving each account a persistent profile, starting each from a script and attaching Playwright or Puppeteer over CDP.

[How to connect to an existing Chrome with CDP](https://mosaicbrowser.com/guides/connect-to-an-existing-chrome-with-cdp): Connect to an existing Chrome with CDP: launch it with --remote-debugging-port and its own --user-data-dir, read /json/version, then attach a client.

[Anti-detect browser REST API: profiles from your scripts](https://mosaicbrowser.com/features/rest-api): Mosaic's anti-detect browser REST API runs on 127.0.0.1 with API keys. Create and start profiles, then attach Puppeteer or Playwright over CDP.

[Anti-detect browser local API: what it is and what to check](https://mosaicbrowser.com/guides/anti-detect-browser-local-api): An anti-detect browser local API is an HTTP server on 127.0.0.1 that creates, starts and stops profiles and hands your script a DevTools endpoint.







[Thirty tabs open: why a test suite needs a fresh tab per site](https://mosaicbrowser.com/blog/one-tab-per-detector): Captcha popups and ad windows left about 30 tabs open in our detector runner. Now each test gets its own tab, and a sweep closes every stray when it ends.

## Run this guide on your own accounts

Every Mosaic profile is a fingerprint, a proxy IP and a cookie jar that agree with each other, kept on your computer. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
