| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A TypeScript port of HumanTyping by @Lax3n.
The most realistic keyboard typing simulator based on Markov Chains and stochastic processes.
HumanTyping models authentic human typing behavior with unprecedented accuracy, making automated typing indistinguishable from real users.
Watch HumanTyping simulate realistic typing with natural speed variations, errors, and corrections.
# With npm
npx jsr add @etareduction/humantypingts
# With Deno
deno add jsr:humantypingtsimport { HumanTyper } from "humantypingts";
import { chromium } from "playwright";
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://google.com");
const typer = new HumanTyper(70); // Create typer
const searchBox = page.locator("[name='q']");
await searchBox.click();
await typer.type(searchBox, "realistic typing!"); // Type like a human!
await browser.close();HumanTyping uses a semi-Markov process where:
The system maintains both a mental cursor (where the user thinks they are) and a physical cursor (actual position), allowing realistic proofreading and corrections.
# With Deno
deno add jsr:humantypingts
# With npm
npx jsr add @etareduction/humantypingts# Clone the repository
git clone https://github.com/etareduction/HumanTypingTS.git
cd HumanTypingTS
# Install dependencies
deno installdeno eval "import { HumanTyper } from './mod.ts'; console.log('✓ Installation successful!')"Watch typing happen in real-time with errors and corrections:
import { demo_single_run } from "humantypingts";
await demo_single_run("Hello world, this is a realistic typing test.", 60);Options:
Generate statistics over multiple simulations:
import { run_monte_carlo } from "humantypingts";
run_monte_carlo("Performance test", 80, 1000);Output:
Running 1000 simulations for text: 'Performance test' (Target WPM: 80) --- Monte Carlo Results --- Estimated Mean Time : 3.2145 s Standard Deviation : 0.4521 s Min / Max : 2.1034 s / 5.8912 s Computation Time : 2.1456 s
The easiest way to add realistic typing to your Playwright scripts:
import { chromium } from "playwright";
import { HumanTyper } from "humantypingts";
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://example.com");
// Create typer with custom WPM
const typer = new HumanTyper(70);
// Type realistically into any input field
const searchBox = page.locator("input[name='search']");
await searchBox.click();
await typer.type(searchBox, "How to type like a human?");
await browser.close();That's it! Just 3 lines of code:
The integration module handles all typing events:
Edit src/humantyping/config.ts to fine-tune the simulation:
// Typing speed
export const DEFAULT_WPM = 60; // Base speed
export const WPM_STD = 10; // Variance between sessions
// Error rates
export const PROB_ERROR = 0.04; // 4% chance of typing wrong key
export const PROB_SWAP_ERROR = 0.015; // 1.5% chance of swapping two characters
export const PROB_NOTICE_ERROR = 0.85; // 85% chance to notice errors immediately
// Speed adjustments
export const SPEED_BOOST_COMMON_WORD = 0.6; // Common words 40% faster
export const SPEED_BOOST_BIGRAM = 0.4; // Frequent bigrams 60% faster
export const SPEED_PENALTY_COMPLEX_WORD = 1.3; // Complex words 30% slower
// Timing (seconds)
export const TIME_SPACE_PAUSE_MEAN = 0.25; // Pause between words
export const TIME_BACKSPACE_MEAN = 0.12; // Backspace press time
export const TIME_ARROW_MEAN = 0.15; // Arrow key navigation time
export const TIME_REACTION_MEAN = 0.35; // "Oops" delay after error
// Fatigue
export const FATIGUE_FACTOR = 1.0005; // 0.05% slowdown per characterHumanTypingTS/ ├── src/ │ ├── humantyping/ │ │ ├── config.ts // All simulation parameters │ │ ├── typer.ts // Core Markov model and state machine │ │ ├── keyboard.ts // QWERTY/AZERTY layouts, key distances │ │ ├── language.ts // Word difficulty, common bigrams │ │ ├── simulation.ts // Demo and Monte Carlo runners │ │ └── integration.ts // Playwright integration │ └── numpy_compat/ // NumPy compatibility layer ├── mod.ts // Main module exports ├── deno.json // Deno configuration └── README.md
Forks and contributions are very welcome!
Ideas for enhancements:
Open an issue or submit a PR!
import { demo_single_run } from "humantypingts";
await demo_single_run("The quick brown fox jumps.", 60);--- Real-Time Simulation Demo: 'The quick brown fox jumps.' (Target WPM: 60.0) --- Preparing simulation... START TYPING: ---------------------------------------- The quick brown fox jumps. ---------------------------------------- Total Simulated Time: 6.2341s Errors made and corrected: 1
MIT License - Feel free to use in your projects!
Built with ❤️ and probabilities by the open-source community.
| Back | FazBrowse Home | New Git URL |