Skip to content
7 min read

Variable Typing Speed: How to Model It Like a Developer

Decorative title card illustration with typing and coding motifs

Variable typing speed means a program deliberately varies the delay between keystrokes instead of firing them at one fixed interval, mimicking how humans actually type. Three approaches dominate real implementations: range-based random delays (pick a random number between a min and max), distribution-based timing (sample from a log-normal or gamma curve that matches real keystroke variance), and character-aware or stateful models (delays that depend on which keys came before). Use range-based for a quick prototype, distribution-based when you need to survive basic statistical scrutiny, and stateful models when realism actually matters.

  • Range-based: fastest to build, easiest to detect as robotic
  • Distribution-based: matches real inter-keystroke interval (IKI) shape, moderate effort
  • Character-aware/stateful: highest fidelity, accounts for bigram speed and fatigue

Always seed your random number generator for reproducibility, and if you’re building this for anything involving academic work or platform terms of service, know the rules before you automate.

Key Takeaways

Realistic variable typing speed requires a skewed timing distribution, character-aware adjustments, typo and correction behavior, and fatigue modeling validated against logged keystroke data.

Point Details
Skip uniform random delays Range-based min/max timing produces detectable flat distributions; use log-normal or gamma instead.
Add character-awareness later Bigram and semi-Markov timing only matter once your base distribution is already validated.
Layer typos and pauses Neighbor-key mistakes and punctuation-based pauses matter as much as raw timing variance.
Model fatigue subtly A small per-character slowdown multiplier avoids obvious linear drift across long sessions.
Validate with real metrics Log IKI distribution, backspace rate, and sliding-window mean speed before trusting your output.

Table of Contents

Three Ways to Simulate Variable Typing Speed

Every typing simulator boils down to one of three timing engines, and picking the wrong one is the fastest way to get flagged.

  1. Range-based random delay. You set a minimum and maximum millisecond value, say 50 to 200ms, and pull a uniform random number between them for every keystroke. It’s ten lines of code and it works for demos. The failure mode is obvious once you look at the data: uniform distributions produce a flat, boxy histogram, while real human inter-keystroke intervals cluster tightly with a long right tail. A detector doesn’t need machine learning to spot a rectangle where a bell curve should be.

  2. Distribution-based timing. Instead of uniform random, you sample from a log-normal or gamma distribution. Both are skewed right, which matches how people type: most keystrokes land close together, but occasional slow ones drag the tail out. A basic sampler needs three things: a shape parameter, a scale parameter, and a hard clamp so you never generate a negative or absurdly long delay.

  3. Character-aware and stateful models. This is where semi-Markov modeling comes in. Instead of one global distribution, you assign different baseline delays to different transitions. Common bigrams like “th” or “in” get typed faster than awkward pairs like “wz” that force a hand reposition. Semi-Markov processes formalize this by letting the “state” (the last character typed) determine the timing distribution for the next one, which is closer to how motor planning actually works during fast typing.

Pro Tip: Don’t jump straight to stateful models. Build the distribution-based version first, log a few thousand keystrokes, and only add character-awareness once you can prove the simpler version isn’t fooling your own test suite.

How Do You Code Variable Typing Speed?

Here’s a minimal JavaScript wrapper for range-based delay, useful as a starting point before you graduate to something better:

function randomDelay(min = 50, max = 200) {
  return Math.random() * (max - min) + min;
}

async function typeText(text, sendChar) {
  for (const char of text) {
    await sendChar(char);
    await new Promise(r => setTimeout(r, randomDelay(50, 200)));
  }
}

That’s the pattern most community projects start with, and it’s fine for a prototype. The pitfall: Math.random() isn’t seedable by default, so your tests won’t be reproducible unless you swap in a seeded PRNG like mulberry32 or seedrandom.

A distribution-based sampler in Python-style pseudocode looks like this:

import numpy as np

rng = np.random.default_rng(seed=42)

def sample_delay(mu=4.0, sigma=0.4, min_ms=30, max_ms=400):
    delay = rng.lognormal(mean=mu, sigma=sigma)
    return max(min_ms, min(delay, max_ms))

The seed=42 argument is what makes your test runs repeatable, which matters enormously once you start comparing “before” and “after” tuning changes.

For character-aware timing, keep a lookup table:

  • Bigram multiplier table: {"th": 0.85, "wz": 1.4, "default": 1.0}
  • Finger-distance multiplier based on QWERTY key coordinates
  • A small JSON config so non-developers can tune ranges without touching code:
{"min_ms": 40, "max_ms": 350, "mu": 4.0, "sigma": 0.35, "seed": 42}

Open-source typing simulators consistently converge on the same three ingredients: variable delay, neighbor-key typos, and thinking pauses. Miss any one of the three and the output still reads as machine-generated, no matter how good your timing distribution is.

What Makes Simulated Typing Look More Human?

Timing alone won’t sell it. Real typists make mistakes and think mid-sentence, and both leave fingerprints your simulation needs to replicate.

  • Typo model: assign each character a small mistake probability (often 1 to 3%), weighted toward physically adjacent keys on the QWERTY layout, then simulate a backspace plus a short pause (150 to 400ms) before the correction.
  • Thinking pauses: apply a multiplier at punctuation. Commas might get a 1.5x delay, periods 2 to 4x, and paragraph breaks 5x or more, since that’s genuinely when people stop to think about the next sentence.
  • Fatigue modeling: a simple approach multiplies the base delay by (1 + k * characters_since_start), where a small k produces a gradual slowdown of only a few percent across a long session rather than an obvious linear drift, a technique grounded in research on fatigue and pauses in human performance.
  • Reset the fatigue counter at natural breakpoints, like after a save action or a multi-minute idle gap, or the slowdown compounds into something that looks scripted instead of human.

Pro Tip: Layer these on top of your distribution sampler, not instead of it. A typo without a variable correction delay is just as detectable as a typo that never happens.

How Do You Test Whether Typing Simulation Looks Real?

You can’t eyeball this. You need numbers.

  1. Log every keystroke timestamp and compute the inter-keystroke interval (IKI) distribution, then compare its shape against a real sample.
  2. Track inter-word pause length separately. Word boundaries produce longer, distinctly-shaped pauses than mid-word keystrokes.
  3. Measure backspace rate as a percentage of total keystrokes, and bigram-level timing variance across common pairs like “er,” “in,” and “th.”
  4. Plot a histogram and a QQ plot against a log-normal reference, and run a Kolmogorov-Smirnov test for a formal distance measure.
  5. Add a sliding-window mean IKI over time. A flat line across a 500-keystroke window is the single biggest tell of a scripted bot, even when the overall distribution passes a KS test.

Baseline your targets against real data: median typing speed sits near 39 to 42 net WPM for average adults, but practiced typists with over 1,000 pages typed average roughly 72.7 WPM versus 44.7 WPM for occasional typists, so your parameter ranges should shift depending on the persona you’re simulating.

How MimicTyper Applies These Same Principles

Hands adjusting metronome dial on desk

MimicTyper’s Mimic V2 engine is built on exactly the three-layer approach this guide walks through: variable pacing sampled from realistic distributions, typo and correction simulation with neighbor-key logic, and an edit history that reflects genuine multi-session drafting rather than one uninterrupted burst.

A few product features map directly onto the concepts above:

  • Typing demo tuning lets you preview pacing before committing to a full document, similar to testing your own sampler against a target IKI distribution.
  • Export file polish cleans up the final Google Docs edit history so revision timestamps and pacing hold up under inspection.
  • Eagle Eye scans drafts for AI-detectable patterns before you submit, functioning as the validation layer this guide recommends you build yourself.

If you’re weighing custom code against a prebuilt extension: building your own semi-Markov typing engine from scratch takes real development time and ongoing tuning against evolving detectors. A tool built specifically for Google Docs realism, with typing demo tuning already dialed in, gets you a defensible edit history without the engineering overhead. MimicTyper is built for students and professionals who want that outcome without maintaining a distribution-fitting pipeline themselves. See how it works.

Which Approach Should Developers Use Next?

Close-up of hands tuning mechanical dial

The strongest predictor of a good outcome here is boring: match your effort to your risk, not to what sounds impressive in a GitHub README.

The judgment this research actually supports is that most projects overinvest in fancy stateful models before they’ve even validated their simple distribution sampler against real data. Semi-Markov modeling is genuinely the right tool for high-stakes realism, but it’s wasted effort if your fatigue multiplier and thinking-pause logic aren’t already tuned. Conventional advice tends to treat “add randomness” as the finish line. It’s the starting line. A uniform random delay between 50 and 200ms will pass a glance test and fail a KS test in about five minutes.

What should you prioritize first? Get the distribution shape right, then layer typos and pauses, then validate with a sliding-window IKI check before you touch bigram tables. Skipping straight to character-aware timing without validating the basics first is how developers end up with elaborate systems that are still detectably robotic, just in a more expensive way.

— MimicTyper

Sources