Press tab in your tests: Introducing cy.press()

April 8, 2025

•

By Jennifer Shehane

Abstract illustration of cy.press() command with text: Introducing cy.press()

Tab key testing is here with cy.press()! This long-requested feature gives you the ability to trigger real native keyboard events in your tests, starting with support for the Tab key.

This is a big step toward improving accessibility testing and ensuring smooth keyboard navigation experiences in your application.

Why we built cy.press()

Historically, Cypress users have relied on cy.type() to simulate keyboard input. While cy.type() is great for typing characters in typeable elements, it doesn't accurately replicate how browsers handle non-character keys like the Tab key.

That’s why we built cy.press(). This new command dispatches native keydown, press, and keyup events directly to the browser.

Start testing keyboard navigation today

With the first release of cy.press(), we’re starting with support for one of the most essential keys for accessibility: the Tab key.

Here’s an example of how you can use it:

it('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')
})

Under the hood, this will dispatch real Tab key events, causing the browser to move focus to the next focusable element just like a real user pressing the Tab key.

Note: cy.press() is currently supported in Chromium browsers and Firefox v135+. WebKit support is not available yet.

What's next? We want your feedback!

We’re releasing cy.press() with Tab support first because it’s one of the most common and important use cases. It’s also one of our most upvoted GitHub issues and we appreciate every comment, link, and example you shared with us. But this is just the beginning.

We plan to expand support to additional keys and functionality but we want to hear from you.

  • What keyboard interactions would you like to test with cy.press()?
  • What challenges do you face testing keyboard navigation today?
  • What would make cy.press() even better?

Drop us a comment on this GitHub issue.

Try it out!

cy.press() is available today in Cypress v14.3.0. Check out the full documentation here and start leveling up your accessibility and keyboard navigation tests.