{
  "doc": {
    "id": "api/commands/press",
    "title": "cy.press() | Cypress Documentation",
    "description": "Trigger native key events in your application to simulate keyboard interactions.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/press.md",
    "version": "3cf5b86b3403f604bdf7f3e35025c3bc3865e02c",
    "updated_at": "2026-05-07T17:44:31.931Z",
    "headings": [
      {
        "id": "api/commands/press#press",
        "text": "press",
        "level": 1
      },
      {
        "id": "api/commands/press#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/press#signature",
        "text": "Signature",
        "level": 2
      },
      {
        "id": "api/commands/press#usage",
        "text": "Usage",
        "level": 2
      },
      {
        "id": "api/commands/press#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/press#supported-keys",
        "text": "Supported Keys",
        "level": 4
      },
      {
        "id": "api/commands/press#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/press#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/press#test-focus-order-of-tab",
        "text": "Test focus order of tab",
        "level": 3
      },
      {
        "id": "api/commands/press#test-autocomplete-of-search-input-with-tab",
        "text": "Test autocomplete of search input with tab",
        "level": 3
      },
      {
        "id": "api/commands/press#type-a-single-character",
        "text": "Type a single character",
        "level": 3
      },
      {
        "id": "api/commands/press#type-a-multi-codepoint-utf-8-character",
        "text": "Type a multi-codepoint UTF-8 character",
        "level": 3
      },
      {
        "id": "api/commands/press#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/press#when-to-use-cy-type",
        "text": "When to use cy.type()",
        "level": 3
      },
      {
        "id": "api/commands/press#strings-with-multiple-characters",
        "text": "Strings with multiple characters",
        "level": 3
      },
      {
        "id": "api/commands/press#transient-activation",
        "text": "Transient activation",
        "level": 3
      },
      {
        "id": "api/commands/press#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/press#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/press#usage",
      "doc_id": "api/commands/press",
      "heading": "Usage",
      "heading_level": 2,
      "content_markdown": "## Usage\n\n**Correct Usage**\n\n```\ncy.get('input.first').focus()cy.press(Cypress.Keyboard.Keys.TAB)cy.get('input.second').should('have.focus')\n```\n\n**Incorrect Usage**\n\n```\ncy.get('input.first').focus()cy.press(Cypress.Keyboard.Keys.TAB)  // Errors because press yields null  .should('have.focus')\n```\n\n### Arguments\n\n**key _(String)_**\n\nThe key to press. Values for non single character keys are available on [`Cypress.Keyboard.Keys`](/llm/markdown/api/cypress-api/keyboard-api.md), and may change from time to time. It's recommended that you reference these values from `Cypress.Keyboard.Keys` rather than passing in a string when available.\n\n#### Supported Keys\n\n| Reference | Value |\n| --- | --- |\n| Letters | `\"a\"` through `\"z\"`, `\"A\"` through `\"Z\"` |\n| Numbers | `\"0\"`, `\"1\"`, `\"2\"`, `\"3\"`, `\"4\"`, `\"5\"`, `\"6\"`, `\"7\"`, `\"8\"`, `\"9\"` |\n| Special Characters | `\"!\"`, `\"@\"`, `\"#\"`, `'+'`, `\"€\"`, `\"é\"`, etc. |\n| `Cypress.Keyboard.Keys.UP` | `\"ArrowUp\"` |\n| `Cypress.Keyboard.Keys.DOWN` | `\"ArrowDown\"` |\n| `Cypress.Keyboard.Keys.LEFT` | `\"ArrowLeft\"` |\n| `Cypress.Keyboard.Keys.RIGHT` | `\"ArrowRight\"` |\n| `Cypress.Keyboard.Keys.ESC` | `\"Escape\"` |\n| `Cypress.Keyboard.Keys.END` | `\"End\"` |\n| `Cypress.Keyboard.Keys.HOME` | `\"Home\"` |\n| `Cypress.Keyboard.Keys.PAGEDOWN` | `\"PageDown\"` |\n| `Cypress.Keyboard.Keys.PAGEUP` | `\"PageUp\"` |\n| `Cypress.Keyboard.Keys.ENTER` | `\"Enter\"` |\n| `Cypress.Keyboard.Keys.TAB` | `\"Tab\"` |\n| `Cypress.Keyboard.Keys.BACKSPACE` | `\"Backspace\"` |\n| `Cypress.Keyboard.Keys.DELETE` | `\"Delete\"` |\n| `Cypress.Keyboard.Keys.INSERT` | `\"Insert\"` |\n| `Cypress.Keyboard.Keys.SPACE` | `\"Space\"` |\n\nF1-F12 keys are not supported. These keys are used for browser shortcuts, and can prevent the test suite from executing properly after they are pressed.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.press()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.press()` to resolve before timing out |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `cy.press()` yields `null`.\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 369
    },
    {
      "id": "api/commands/press#arguments",
      "doc_id": "api/commands/press",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**key _(String)_**\n\nThe key to press. Values for non single character keys are available on [`Cypress.Keyboard.Keys`](/llm/markdown/api/cypress-api/keyboard-api.md), and may change from time to time. It's recommended that you reference these values from `Cypress.Keyboard.Keys` rather than passing in a string when available.\n\n#### Supported Keys\n\n| Reference | Value |\n| --- | --- |\n| Letters | `\"a\"` through `\"z\"`, `\"A\"` through `\"Z\"` |\n| Numbers | `\"0\"`, `\"1\"`, `\"2\"`, `\"3\"`, `\"4\"`, `\"5\"`, `\"6\"`, `\"7\"`, `\"8\"`, `\"9\"` |\n| Special Characters | `\"!\"`, `\"@\"`, `\"#\"`, `'+'`, `\"€\"`, `\"é\"`, etc. |\n| `Cypress.Keyboard.Keys.UP` | `\"ArrowUp\"` |\n| `Cypress.Keyboard.Keys.DOWN` | `\"ArrowDown\"` |\n| `Cypress.Keyboard.Keys.LEFT` | `\"ArrowLeft\"` |\n| `Cypress.Keyboard.Keys.RIGHT` | `\"ArrowRight\"` |\n| `Cypress.Keyboard.Keys.ESC` | `\"Escape\"` |\n| `Cypress.Keyboard.Keys.END` | `\"End\"` |\n| `Cypress.Keyboard.Keys.HOME` | `\"Home\"` |\n| `Cypress.Keyboard.Keys.PAGEDOWN` | `\"PageDown\"` |\n| `Cypress.Keyboard.Keys.PAGEUP` | `\"PageUp\"` |\n| `Cypress.Keyboard.Keys.ENTER` | `\"Enter\"` |\n| `Cypress.Keyboard.Keys.TAB` | `\"Tab\"` |\n| `Cypress.Keyboard.Keys.BACKSPACE` | `\"Backspace\"` |\n| `Cypress.Keyboard.Keys.DELETE` | `\"Delete\"` |\n| `Cypress.Keyboard.Keys.INSERT` | `\"Insert\"` |\n| `Cypress.Keyboard.Keys.SPACE` | `\"Space\"` |\n\nF1-F12 keys are not supported. These keys are used for browser shortcuts, and can prevent the test suite from executing properly after they are pressed.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.press()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.press()` to resolve before timing out |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 331
    },
    {
      "id": "api/commands/press#supported-keys",
      "doc_id": "api/commands/press",
      "heading": "Supported Keys",
      "heading_level": 4,
      "content_markdown": "#### Supported Keys\n\n| Reference | Value |\n| --- | --- |\n| Letters | `\"a\"` through `\"z\"`, `\"A\"` through `\"Z\"` |\n| Numbers | `\"0\"`, `\"1\"`, `\"2\"`, `\"3\"`, `\"4\"`, `\"5\"`, `\"6\"`, `\"7\"`, `\"8\"`, `\"9\"` |\n| Special Characters | `\"!\"`, `\"@\"`, `\"#\"`, `'+'`, `\"€\"`, `\"é\"`, etc. |\n| `Cypress.Keyboard.Keys.UP` | `\"ArrowUp\"` |\n| `Cypress.Keyboard.Keys.DOWN` | `\"ArrowDown\"` |\n| `Cypress.Keyboard.Keys.LEFT` | `\"ArrowLeft\"` |\n| `Cypress.Keyboard.Keys.RIGHT` | `\"ArrowRight\"` |\n| `Cypress.Keyboard.Keys.ESC` | `\"Escape\"` |\n| `Cypress.Keyboard.Keys.END` | `\"End\"` |\n| `Cypress.Keyboard.Keys.HOME` | `\"Home\"` |\n| `Cypress.Keyboard.Keys.PAGEDOWN` | `\"PageDown\"` |\n| `Cypress.Keyboard.Keys.PAGEUP` | `\"PageUp\"` |\n| `Cypress.Keyboard.Keys.ENTER` | `\"Enter\"` |\n| `Cypress.Keyboard.Keys.TAB` | `\"Tab\"` |\n| `Cypress.Keyboard.Keys.BACKSPACE` | `\"Backspace\"` |\n| `Cypress.Keyboard.Keys.DELETE` | `\"Delete\"` |\n| `Cypress.Keyboard.Keys.INSERT` | `\"Insert\"` |\n| `Cypress.Keyboard.Keys.SPACE` | `\"Space\"` |\n\nF1-F12 keys are not supported. These keys are used for browser shortcuts, and can prevent the test suite from executing properly after they are pressed.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.press()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.press()` to resolve before timing out |\n",
      "section": "api",
      "anchors": [
        "supported-keys"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 275
    },
    {
      "id": "api/commands/press#examples",
      "doc_id": "api/commands/press",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Test focus order of tab\n\n```\nit('moves focus to the next form element when pressing Tab', () => {  cy.visit('/my-login')  cy.get('input.email').type('username')  cy.press(Cypress.Keyboard.Keys.TAB)  cy.get('input.password').should('have.focus')})\n```\n\n### Test autocomplete of search input with tab\n\n```\nit('autocompletes search input when pressing Tab', () => {  cy.get('[data-cy=\"search\"]').type('cy')  cy.press(Cypress.Keyboard.Keys.TAB)  cy.get('[data-cy=\"search\"]').should('have.value', 'cypress')})\n```\n\n### Type a single character\n\nSingle character keys are supported, like `a`, `b`, `c`, etc. There is no need to reference `Cypress.Keyboard.Keys` record for these keys, just type them normally as a string:\n\n```\ncy.get('input').focus()cy.press('a')\n```\n\n### Type a multi-codepoint UTF-8 character\n\nMulti-codepoint UTF-8 characters are also supported and do not need to be entered as individual codepoints. For example, `é` can be either one single codepoint or two separate codepoints when the accent is pressed as a subsequent modifier key. You do not need to press each codepoint separately; just type the entire character as a string.\n\n```\n// workscy.get('input').focus()cy.press('é') // \\u00e9 (composed é)cy.press('é') // \\u0065\\u0301 (e + combining acute accent)// also fine, but not necessarycy.get('input').focus()cy.press('e') // \\u0065cy.press('́') // \\u0301 (combining acute accent)\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 233
    },
    {
      "id": "api/commands/press#type-a-single-character",
      "doc_id": "api/commands/press",
      "heading": "Type a single character",
      "heading_level": 3,
      "content_markdown": "### Type a single character\n\nSingle character keys are supported, like `a`, `b`, `c`, etc. There is no need to reference `Cypress.Keyboard.Keys` record for these keys, just type them normally as a string:\n\n```\ncy.get('input').focus()cy.press('a')\n```\n",
      "section": "api",
      "anchors": [
        "type-a-single-character"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 48
    },
    {
      "id": "api/commands/press#type-a-multi-codepoint-utf-8-character",
      "doc_id": "api/commands/press",
      "heading": "Type a multi-codepoint UTF-8 character",
      "heading_level": 3,
      "content_markdown": "### Type a multi-codepoint UTF-8 character\n\nMulti-codepoint UTF-8 characters are also supported and do not need to be entered as individual codepoints. For example, `é` can be either one single codepoint or two separate codepoints when the accent is pressed as a subsequent modifier key. You do not need to press each codepoint separately; just type the entire character as a string.\n\n```\n// workscy.get('input').focus()cy.press('é') // \\u00e9 (composed é)cy.press('é') // \\u0065\\u0301 (e + combining acute accent)// also fine, but not necessarycy.get('input').focus()cy.press('e') // \\u0065cy.press('́') // \\u0301 (combining acute accent)\n```\n",
      "section": "api",
      "anchors": [
        "type-a-multi-codepoint-utf-8-character"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 119
    },
    {
      "id": "api/commands/press#notes",
      "doc_id": "api/commands/press",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### When to use cy.type()\n\nWhile `.press()` dispatches native keyboard events, use [`cy.type()`](/llm/markdown/api/commands/type.md) for:\n\n*   **Text input**: Typing multiple characters or words\n*   **Special character sequences**: `{backspace}`, `{selectAll}`, `{moveToEnd}`\n*   **Modifier combinations**: `{ctrl}c`, `{shift}b`\n*   **Form filling**: When you need to simulate specific timing of typing behavior\n\n```\n// Use .press() for single key eventscy.press(Cypress.Keyboard.Keys.TAB)// Use .type() for text and complex sequencescy.get('input').type('Hello{backspace}World')\n```\n\n### Strings with multiple characters\n\nStrings with multiple characters are not supported. If you need to input longer strings into a text input or similar, use [`cy.type()`](/llm/markdown/api/commands/type.md).\n\n```\ncy.get('input').type('Hello, World') // Type 'Hello, World' into the 'input'\n```\n\n### Transient activation\n\nBy dispatching native keyboard events to the browser, this command will cause the browser to enter [Transient activation](https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation) state.\n\nIf your application prevents the default behavior of the `beforeunload` event, this may cause issues when navigating away from the current page.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 196
    },
    {
      "id": "api/commands/press#when-to-use-cy-type",
      "doc_id": "api/commands/press",
      "heading": "When to use cy.type()",
      "heading_level": 3,
      "content_markdown": "### When to use cy.type()\n\nWhile `.press()` dispatches native keyboard events, use [`cy.type()`](/llm/markdown/api/commands/type.md) for:\n\n*   **Text input**: Typing multiple characters or words\n*   **Special character sequences**: `{backspace}`, `{selectAll}`, `{moveToEnd}`\n*   **Modifier combinations**: `{ctrl}c`, `{shift}b`\n*   **Form filling**: When you need to simulate specific timing of typing behavior\n\n```\n// Use .press() for single key eventscy.press(Cypress.Keyboard.Keys.TAB)// Use .type() for text and complex sequencescy.get('input').type('Hello{backspace}World')\n```\n",
      "section": "api",
      "anchors": [
        "when-to-use-cy-type"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 84
    },
    {
      "id": "api/commands/press#strings-with-multiple-characters",
      "doc_id": "api/commands/press",
      "heading": "Strings with multiple characters",
      "heading_level": 3,
      "content_markdown": "### Strings with multiple characters\n\nStrings with multiple characters are not supported. If you need to input longer strings into a text input or similar, use [`cy.type()`](/llm/markdown/api/commands/type.md).\n\n```\ncy.get('input').type('Hello, World') // Type 'Hello, World' into the 'input'\n```\n",
      "section": "api",
      "anchors": [
        "strings-with-multiple-characters"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 51
    },
    {
      "id": "api/commands/press#transient-activation",
      "doc_id": "api/commands/press",
      "heading": "Transient activation",
      "heading_level": 3,
      "content_markdown": "### Transient activation\n\nBy dispatching native keyboard events to the browser, this command will cause the browser to enter [Transient activation](https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation) state.\n\nIf your application prevents the default behavior of the `beforeunload` event, this may cause issues when navigating away from the current page.\n",
      "section": "api",
      "anchors": [
        "transient-activation"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 59
    },
    {
      "id": "api/commands/press#history",
      "doc_id": "api/commands/press",
      "heading": "History",
      "heading_level": 2,
      "content_markdown": "## History\n\n| Version | Changes |\n| --- | --- |\n| [15.3.0](/llm/markdown/app/references/changelog.md) | Added support for `{esc}` key. |\n| [15.1.0](/llm/markdown/app/references/changelog.md) | Expanded support to include named keys and single+multi-codepoint UTF-8 characters. |\n| [14.3.0](/llm/markdown/app/references/changelog.md) | Added the `.press()` command |\n",
      "section": "api",
      "anchors": [
        "history"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 57
    },
    {
      "id": "api/commands/press#see-also",
      "doc_id": "api/commands/press",
      "heading": "See also",
      "heading_level": 2,
      "content_markdown": "## See also\n\n*   [`cy.type()`](/llm/markdown/api/commands/type.md) - For typing text and special sequences\n*   [`.focus()`](/llm/markdown/api/commands/focus.md) - Focus elements before pressing keys\n*   [`.focused()`](/llm/markdown/api/commands/focused.md) - Assert focused elements\n*   [`.click()`](/llm/markdown/api/commands/click.md) - Click elements\n*   [`Cypress.Keyboard`](/llm/markdown/api/cypress-api/keyboard-api.md) - Keyboard constants\n*   [Accessibility Testing Guide](/llm/markdown/app/guides/accessibility-testing.md) - Keyboard navigation patterns\n",
      "section": "api",
      "anchors": [
        "see-also"
      ],
      "path": "/llm/json/chunked/api/commands/press.json",
      "token_estimate": 59
    }
  ]
}