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
53 changes: 52 additions & 1 deletion 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 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 |

<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,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
Expand All @@ -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
Expand All @@ -282,9 +321,21 @@ kernel browsers computer type <session id> --text "Hello, World!"

# Type text with a 100ms delay between keystrokes
kernel browsers computer type <session id> --text "Slow typing..." --delay 100

# Human-like smooth typing
kernel browsers computer type <session id> --text "The quick brown fox" --smooth

# Human-like with occasional typos
kernel browsers computer type <session id> --text "The quick brown fox" --smooth --typo-chance 0.03
```
</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.