diff --git a/browsers/computer-controls.mdx b/browsers/computer-controls.mdx index 7e0a1a0..1b13bf5 100644 --- a/browsers/computer-controls.mdx +++ b/browsers/computer-controls.mdx @@ -239,7 +239,14 @@ kernel browsers computer screenshot --to region.png --x 0 --y 0 --w ## Type text -Type literal text, optionally with a delay in milliseconds between keystrokes. +Type literal text with optional human-like timing. When `smooth` is enabled, text is typed in word-sized chunks with variable inter-key delays and natural pauses at word and sentence boundaries. You can also inject realistic typos that are automatically corrected with backspace. + +| Parameter | Type | Default | Description | +| ------------- | ------- | ------- | ----------- | +| `text` | string | — | Text to type | +| `delay` | integer | `0` | Fixed delay in milliseconds between keystrokes. Ignored when `smooth` is `true` | +| `smooth` | boolean | `false` | Use human-like variable keystroke timing with word-boundary pauses | +| `typo_chance` | number | `0` | Probability (0.0–0.10) of a typo per character, corrected with backspace. Requires `smooth: true` (silently ignored otherwise). Typical human range is 0.02–0.05 | ```typescript Typescript/Javascript @@ -248,14 +255,29 @@ import Kernel from '@onkernel/sdk'; const kernel = new Kernel(); const kernelBrowser = await kernel.browsers.create(); +// Instant typing (default) await kernel.browsers.computer.typeText(kernelBrowser.session_id, { text: 'Hello, World!', }); +// Fixed delay between keystrokes await kernel.browsers.computer.typeText(kernelBrowser.session_id, { text: 'Slow typing...', delay: 100, }); + +// Human-like smooth typing +await kernel.browsers.computer.typeText(kernelBrowser.session_id, { + text: 'The quick brown fox jumps over the lazy dog.', + smooth: true, +}); + +// Human-like with occasional typos (3% chance per character) +await kernel.browsers.computer.typeText(kernelBrowser.session_id, { + text: 'The quick brown fox jumps over the lazy dog.', + smooth: true, + typo_chance: 0.03, +}); ``` ```python Python @@ -264,16 +286,33 @@ from kernel import Kernel kernel = Kernel() kernel_browser = kernel.browsers.create() +# Instant typing (default) kernel.browsers.computer.type_text( id=kernel_browser.session_id, text="Hello, World!", ) +# Fixed delay between keystrokes kernel.browsers.computer.type_text( id=kernel_browser.session_id, text="Slow typing...", delay=100, ) + +# Human-like smooth typing +kernel.browsers.computer.type_text( + id=kernel_browser.session_id, + text="The quick brown fox jumps over the lazy dog.", + smooth=True, +) + +# Human-like with occasional typos (3% chance per character) +kernel.browsers.computer.type_text( + id=kernel_browser.session_id, + text="The quick brown fox jumps over the lazy dog.", + smooth=True, + typo_chance=0.03, +) ``` ```bash CLI @@ -282,9 +321,21 @@ kernel browsers computer type --text "Hello, World!" # Type text with a 100ms delay between keystrokes kernel browsers computer type --text "Slow typing..." --delay 100 + +# Human-like smooth typing +kernel browsers computer type --text "The quick brown fox" --smooth + +# Human-like with occasional typos +kernel browsers computer type --text "The quick brown fox" --smooth --typo-chance 0.03 ``` +### Smooth vs instant typing + + + + + ## Press keys Press one or more key symbols (including combinations like "Ctrl+t" or "Ctrl+Shift+Tab"). Optionally hold modifiers and/or set a duration to hold keys down. diff --git a/images/smooth-typing-demo.gif b/images/smooth-typing-demo.gif new file mode 100644 index 0000000..649821a Binary files /dev/null and b/images/smooth-typing-demo.gif differ