Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 56 additions & 5 deletions browsers/computer-controls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,14 @@ kernel browsers computer screenshot <session id> --to region.png --x 0 --y 0 --w

## Type text

Type literal text, optionally with a delay in milliseconds between keystrokes.
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`.

| Parameter | Type | Default | Description |
| ------------- | ------- | ------- | ----------- |
| `text` | string | — | Text to type |
| `delay` | integer | `0` | Fixed delay in milliseconds between keystrokes. Only used when `smooth` is `false`; ignored when `smooth` is `true` |
| `smooth` | boolean | `true` | Human-like variable keystroke timing with word-boundary pauses (default, same idea as `moveMouse` / `dragMouse`) |
| `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 |

<CodeGroup>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional/minor: typo_chance is silently ignored when passed without smooth: true (no error, just no effect). Might be worth a brief parenthetical in the description — e.g. "Requires smooth: true (silently ignored otherwise)" — so users don't pass it standalone and wonder why nothing happens.

```typescript Typescript/Javascript
Expand All @@ -248,12 +255,27 @@ import Kernel from '@onkernel/sdk';
const kernel = new Kernel();
const kernelBrowser = await kernel.browsers.create();

// Human-like smooth typing (default — omit smooth or pass true)
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
text: 'The quick brown fox jumps over the lazy dog.',
});

// 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.',
typo_chance: 0.03,
});

// Instant typing (all at once, no per-key delay)
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
text: 'Hello, World!',
smooth: false,
});

// Fixed delay between keystrokes (smooth off)
await kernel.browsers.computer.typeText(kernelBrowser.session_id, {
text: 'Slow typing...',
smooth: false,
delay: 100,
});
```
Expand All @@ -264,27 +286,56 @@ from kernel import Kernel
kernel = Kernel()
kernel_browser = kernel.browsers.create()

# Human-like smooth typing (default — omit smooth or pass True)
kernel.browsers.computer.type_text(
id=kernel_browser.session_id,
text="The quick brown fox jumps over the lazy dog.",
)

# 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.",
typo_chance=0.03,
)

# Instant typing (all at once, no per-key delay)
kernel.browsers.computer.type_text(
id=kernel_browser.session_id,
text="Hello, World!",
smooth=False,
)

# Fixed delay between keystrokes (smooth off)
kernel.browsers.computer.type_text(
id=kernel_browser.session_id,
text="Slow typing...",
smooth=False,
delay=100,
)
```

```bash CLI
# Type text in the browser
kernel browsers computer type <session id> --text "Hello, World!"
# Human-like smooth typing (default)
kernel browsers computer type <session id> --text "The quick brown fox"

# Human-like with occasional typos
kernel browsers computer type <session id> --text "The quick brown fox" --typo-chance 0.03

# Instant typing (all at once)
kernel browsers computer type <session id> --text "Hello, World!" --smooth=false

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

### Smooth vs instant typing

<Frame caption="Instant typing (all at once) vs smooth human-like typing with variable delays and typo correction">
<img src="/images/smooth-typing-demo.gif" />
</Frame>

## 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.
Expand Down
Binary file added images/smooth-typing-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.