Skip to content

Commit edc05bb

Browse files
docs: add smooth typing with typo injection to computer controls (#321)
* docs: add smooth typing with typo injection to computer controls Adds documentation for the new smooth and typo_chance parameters on the type_text endpoint, with code examples in TS, Python, and CLI. Includes demo GIF and MP4 showing instant vs smooth vs smooth+typos. Made-with: Cursor * Address review: clarify typo_chance behavior, remove unreferenced MP4 - Note that typo_chance is silently ignored without smooth: true - Remove smooth-typing-demo.mp4 since only the GIF is embedded Made-with: Cursor * docs: default smooth typing to true (align kernel-images#201) - Type text section: smooth defaults true like moveMouse/dragMouse; clarify delay and typo_chance only apply when smooth is on/off respectively. - Reorder TS/Python/CLI examples: smooth + typos first; instant/fixed delay use smooth false. Made-with: Cursor * docs: keep typo_chance semantics in Type text table only OpenAPI carries bounds; docs explain 0–0.10 and ~10% per character. Made-with: Cursor
1 parent 7c0ea96 commit edc05bb

2 files changed

Lines changed: 56 additions & 5 deletions

File tree

browsers/computer-controls.mdx

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ kernel browsers computer screenshot <session id> --to region.png --x 0 --y 0 --w
217217

218218
## Type text
219219

220-
Type literal text, optionally with a delay in milliseconds between keystrokes.
220+
Type literal text on the host. By default, typing uses human-like variable timing: word-sized chunks, natural pauses at word and sentence boundaries, and optional realistic typos corrected with backspace. Set `smooth: false` for xdotool typing with a fixed per-keystroke delay (`delay`, in ms) or instant input when `delay` is `0`.
221+
222+
| Parameter | Type | Default | Description |
223+
| ------------- | ------- | ------- | ----------- |
224+
| `text` | string || Text to type |
225+
| `delay` | integer | `0` | Fixed delay in milliseconds between keystrokes. Only used when `smooth` is `false`; ignored when `smooth` is `true` |
226+
| `smooth` | boolean | `true` | Human-like variable keystroke timing with word-boundary pauses (default, same idea as `moveMouse` / `dragMouse`) |
227+
| `typo_chance` | number | `0` | Per-character typo rate from 0–0.10 (capped; 0.10 ≈ 10% per character on average), corrected with backspace. Only applies when `smooth` is `true` (silently ignored when `smooth` is `false`). Typical values are 0.02–0.05 |
221228

222229
<CodeGroup>
223230
```typescript Typescript/Javascript
@@ -226,12 +233,27 @@ import Kernel from '@onkernel/sdk';
226233
const kernel = new Kernel();
227234
const kernelBrowser = await kernel.browsers.create();
228235

236+
// Human-like smooth typing (default — omit smooth or pass true)
237+
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
238+
text: 'The quick brown fox jumps over the lazy dog.',
239+
});
240+
241+
// Human-like with occasional typos (3% chance per character)
242+
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
243+
text: 'The quick brown fox jumps over the lazy dog.',
244+
typo_chance: 0.03,
245+
});
246+
247+
// Instant typing (all at once, no per-key delay)
229248
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
230249
text: 'Hello, World!',
250+
smooth: false,
231251
});
232252

253+
// Fixed delay between keystrokes (smooth off)
233254
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
234255
text: 'Slow typing...',
256+
smooth: false,
235257
delay: 100,
236258
});
237259
```
@@ -242,27 +264,56 @@ from kernel import Kernel
242264
kernel = Kernel()
243265
kernel_browser = kernel.browsers.create()
244266

267+
# Human-like smooth typing (default — omit smooth or pass True)
268+
kernel.browsers.computer.type_text(
269+
id=kernel_browser.session_id,
270+
text="The quick brown fox jumps over the lazy dog.",
271+
)
272+
273+
# Human-like with occasional typos (3% chance per character)
274+
kernel.browsers.computer.type_text(
275+
id=kernel_browser.session_id,
276+
text="The quick brown fox jumps over the lazy dog.",
277+
typo_chance=0.03,
278+
)
279+
280+
# Instant typing (all at once, no per-key delay)
245281
kernel.browsers.computer.type_text(
246282
id=kernel_browser.session_id,
247283
text="Hello, World!",
284+
smooth=False,
248285
)
249286

287+
# Fixed delay between keystrokes (smooth off)
250288
kernel.browsers.computer.type_text(
251289
id=kernel_browser.session_id,
252290
text="Slow typing...",
291+
smooth=False,
253292
delay=100,
254293
)
255294
```
256295

257296
```bash CLI
258-
# Type text in the browser
259-
kernel browsers computer type <session id> --text "Hello, World!"
297+
# Human-like smooth typing (default)
298+
kernel browsers computer type <session id> --text "The quick brown fox"
299+
300+
# Human-like with occasional typos
301+
kernel browsers computer type <session id> --text "The quick brown fox" --typo-chance 0.03
302+
303+
# Instant typing (all at once)
304+
kernel browsers computer type <session id> --text "Hello, World!" --smooth=false
260305

261-
# Type text with a 100ms delay between keystrokes
262-
kernel browsers computer type <session id> --text "Slow typing..." --delay 100
306+
# Fixed delay between keystrokes (smooth off)
307+
kernel browsers computer type <session id> --text "Slow typing..." --smooth=false --delay 100
263308
```
264309
</CodeGroup>
265310

311+
### Smooth vs instant typing
312+
313+
<Frame caption="Instant typing (all at once) vs smooth human-like typing with variable delays and typo correction">
314+
<img src="/images/smooth-typing-demo.gif" />
315+
</Frame>
316+
266317
## Press keys
267318

268319
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.

images/smooth-typing-demo.gif

1.46 MB
Loading

0 commit comments

Comments
 (0)