When we first introduced cy.press()
in Cypress 14.3.0, it unlocked something our community had been asking for: a way to send real, native keyboard events to the browser. The initial release focused on one of the most important keys for accessibility testing: Tab, so you could confidently verify focus management and keyboard navigation.
With Cypress 15.1.0, we've expanded support far beyond Tab. You can now use cy.press()
to simulate letters, numbers, special characters, and a wide range of named keys. Each key press triggers a genuine keydown and keyup event in the browser.
What’s New in 15.1.0
You can now pass any of the following into cy.press()
:
- Letters: "a" through "z", "A" through "Z"
- Numbers: "0" through "9"
- Special characters: "!", "@", "#", "+", "€", "é", and more
- Named keys:
- Cypress.Keyboard.Keys.TAB
- Cypress.Keyboard.Keys.ENTER
- Cypress.Keyboard.Keys.SPACE
- Cypress.Keyboard.Keys.BACKSPACE
- Cypress.Keyboard.Keys.DELETE
- Cypress.Keyboard.Keys.INSERT
- Cypress.Keyboard.Keys.HOME
- Cypress.Keyboard.Keys.END
- Cypress.Keyboard.Keys.UP
- Cypress.Keyboard.Keys.DOWN
- Cypress.Keyboard.Keys.PAGEUP
- Cypress.Keyboard.Keys.PAGEDOWN
⚠️ Note: Function keys (F1 through F12) are not supported. These keys are reserved for browser-level shortcuts and can interrupt your test runs.
Why This Matters
Keyboard navigation is essential for building accessible applications as well as testing the behavior of keyboard shortcuts. Until now, Cypress users often relied on .type()
to simulate keystrokes. While .type()
is great for typing text in inputs, textareas, and other type-able elements, it doesn't always behave like a real user pressing physical keys, especially for non-character keys like arrows, Enter, or Backspace.
By dispatching real native events, cy.press()
lets you:
- Validate focus order: Ensure that Tab moves focus predictably across interactive elements.
- Test keyboard shortcuts: Simulate Enter, Space, and arrow key interactions.
- Improve accessibility testing: Catch issues that simulated typing might miss, including improper handling of focus traps or keyboard navigation flows.
Examples
Navigate with tab and arrow keys
// Moves focus down in a list
cy.press(Cypress.Keyboard.Keys.TAB)
cy.focused().should('contain.text', 'First item')
cy.press(Cypress.Keyboard.Keys.DOWN)
cy.focused().should('contain.text', 'Second item')
Use Enter to submit
cy.get('input.search').type('Cypress')
cy.press(Cypress.Keyboard.Keys.ENTER)
cy.url().should('include', '/search?q=Cypress')
Start Using It Today
The expanded key support is available now in Cypress 15.1.0. Update your project and start testing more realistic keyboard interactions, from simple typing to complex navigation and accessibility workflows.
👉 Read the full cy.press() documentation for the complete list of supported keys and usage examples.
Go Further with Cypress Accessibility
If you care about making your application truly accessible, cy.press()
is just the beginning. Cypress offers a dedicated Accessibility Testing solution that helps you automatically catch accessibility issues, integrate audits into CI, and share detailed reports with your team. Combine keyboard interaction testing with automated accessibility checks to ensure your app works for everyone.