> For the complete documentation index, see [llms.txt](https://docs.bugbug.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bugbug.io/recording-tests-steps/recording-keyboard-typing.md).

# Recording keyboard typing

How BugBug records typing as a Type text step, how to press keys such as Enter, Tab, Escape and arrows in a test, and how password fields are saved as secret values.

During the recording, BugBug will automatically record everything you type in the text fields. You don't need to activate anything.

You can later [edit the recorded text manually](https://docs.bugbug.io/editing-tests/manually-creating-the-test.md) if needed. Typing is reflected by `Type text` type of action.

{% hint style="info" %}
**Did you know?** When running a test, BugBug will simulate every keystroke, as if the user was really typing the text letter by letter. Learn more about [running tests](https://docs.bugbug.io/running-tests/running-tests.md).
{% endhint %}

![](https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2F0mxpYI4S2dpupTUSZr23%2Fimage.png?alt=media\&token=2e8f2c70-096e-4c1f-a610-125ca34341b7)

## Recording keys

When you type in a field during recording, BugBug records the text and special keys such as Enter, Tab, Escape, Backspace and arrows in a Type text step. After Enter or Tab, the next keys you type start a new step. Keys pressed together with Ctrl or Command (⌘) are not recorded.

## Pressing keys in a test

There is no separate "press key" step. To press a key, use a [Type text](https://docs.bugbug.io/editing-tests/actions.md#type-text) step and put a key sequence in its value, for example `{enter}`, `{tab}` or `{esc}`. The value can contain only the sequence, or text and sequences together, such as `running shoes{enter}`.

| Key       | Sequence      | Key         | Sequence  |
| --------- | ------------- | ----------- | --------- |
| Enter     | `{enter}`     | Arrow left  | `{left}`  |
| Tab       | `{tab}`       | Arrow right | `{right}` |
| Escape    | `{esc}`       | Arrow up    | `{up}`    |
| Backspace | `{backspace}` | Arrow down  | `{down}`  |
| Delete    | `{delete}`    | Home        | `{home}`  |
| Page Up   | `{pageup}`    | End         | `{end}`   |
| Page Down | `{pagedown}`  | Space       | a space   |

### How it works

* **The keys go to the step's element.** Select the element that should receive the keys, such as the input, the slider handle or the menu. With the **Element has focus** [waiting condition](https://docs.bugbug.io/preventing-failed-tests/waiting-conditions.md), which is on by default for Type text, BugBug focuses the element first if it isn't focused.
* **Every key event must reach that element.** If focus moves to another element in the middle of the value, the step fails with `EVENT_DISPATCHED_ON_INVALID_ELEMENT`. Put `{tab}` at the end of the value, and start a new Type text step for the next field.
* **Keys are pressed one by one.** Each key is pressed and released before the next one, so sequences like `{ctrl}` don't hold the key down for the next character.

```yaml
- action: type
  name: Close the modal
  action_details:
    selector: "xpath=//*[@role='dialog']"
    value: "{esc}"
```

## Good to know

* **Password fields.** Text typed into a password field (`<input type="password">`) is saved as a secret value, so it's hidden in the step.
* **Password managers.** Don't fill fields with a password manager while recording. BugBug turns off the autofill of the password managers it detects, because it changes the page. See [Other browser extensions can change the page](https://docs.bugbug.io/troubleshooting/prohibited-behaviors.md).
* **Variables.** To type a value that changes in every run, such as a unique email, insert a [variable](https://docs.bugbug.io/editing-tests/variables.md) with **Variables** in the recording overlay.

## FAQ

<details>

<summary>How do I press Enter, Tab or Escape in a test?</summary>

Add a **Type text** step on the element that should receive the key, and set its value to `{enter}`, `{tab}` or `{esc}`. There is no separate "press key" step. See [Pressing keys in a test](#pressing-keys-in-a-test).

</details>

<details>

<summary>How do I press an arrow key on a focused element, for example a slider?</summary>

Add a **Type text** step with the element's selector and the value `{right}` (or `{left}`, `{up}`, `{down}`). Repeat the sequence to press it several times, for example `{right}{right}{right}`.

</details>

<details>

<summary>Can I press key combinations like Ctrl+A or Ctrl+C?</summary>

Not with Type text: it presses and releases each key separately. To clear a field, use a **Clear input** step. To paste, use **Paste from clipboard**.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bugbug.io/recording-tests-steps/recording-keyboard-typing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
