Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cy.press() is Cypress’s command for dispatching an individual native keyboard event, especially for testing Tab movement, focus behavior, and keyboard navigation. Cypress introduced it in 14.3.0 for Tab; later releases expanded the supported keys. Use cy.type() instead when entering text or sending supported special-character and modifier sequences.

What cy.press() does

The current Cypress API describes cy.press() as dispatching keydown and keyup directly to the browser window. It is designed for a single key interaction, such as moving focus with Tab or exercising an application’s response to an arrow key, Enter, or Escape. Cypress says the command yields null, so make assertions in a following Cypress command rather than chaining an assertion onto cy.press().

For named keys, use Cypress.Keyboard.Keys constants where available. Cypress cautions that key values may change. The current reference lists letters, numbers, special characters, and multi-codepoint UTF-8 characters as supported. It does not support multi-character strings or F1–F12 with cy.press(). See the cy.press() API reference.

What changed in cy.press()

Version Change
14.3.0 (April 8, 2025) Introduced cy.press() with native Tab event support.
15.1.0 Expanded support for named keys and single- and multi-codepoint UTF-8 characters.
15.3.0 Added {esc} key support.
15.19.0 Fixed a small renderer-memory retention issue associated with each cy.press() call in Chromium-based browsers. This is a historical changelog entry; it does not establish that the issue remains in current releases.

These changes are recorded in Cypress’s changelog and the API reference’s history. Check the documentation for the Cypress version installed in your project before relying on a particular key or behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.

When to use cy.press() instead of cy.type()

Need Use Example
One native key event for navigation or focus behavior cy.press() Tab to the next control, press an arrow key, or activate a focused control with Enter.
Text entry, form filling, or a supported special-key/modifier sequence cy.type() Enter a name, type a string, or send a sequence such as {ctrl}c or {shift}b.

cy.type() remains the right fit for words and multi-key sequences. Its documentation also suggests cy.press() for navigation keys in non-form contexts when more accurate native keyboard simulation is wanted. See the cy.type() API reference.

Test keyboard navigation and focus

Use a key constant, then assert the resulting application state on the element that should receive focus. For example:

Rank #2
Sale
Logitech MK270 Full Size Wireless Keyboard and Mouse Combo - Black
  • Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
  • Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
  • Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
  • Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
  • Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
cy.visit('/settings')

cy.get('[data-cy="first-field"]').focus()
cy.press(Cypress.Keyboard.Keys.TAB)
cy.get('[data-cy="second-field"]').should('be.focused')

This checks the outcome rather than merely confirming that a key command ran. Cypress’s accessibility testing guide identifies keyboard-only page navigation and custom interactions such as autocomplete as useful cases. For an autocomplete, for example, press an arrow key and assert the intended option is selected or focused; do not treat dispatching the key alone as proof that the interaction is accessible.

Cypress app shortcuts are different

Cypress’s open-mode shortcuts operate the Cypress app, not the application under test. They are separate from the cy.press() command inside a test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*
Shortcut Action in Cypress open mode
r Reruns tests.
s Stops tests.
f Focuses the Specs window.
⌘+s on macOS; Ctrl+s on Windows/Linux Saves Studio changes when Studio is open and there are unsaved changes.

See Cypress’s open-mode documentation for app shortcuts.

Troubleshooting cy.press()

  • An assertion chained to cy.press() fails: the command yields null. Put the assertion in a subsequent command, such as cy.get(...).should('be.focused').
  • A multi-character value is rejected: cy.press() handles one key, not a string of text. Use cy.type() to enter text or a supported sequence.
  • An F1–F12 key is unsupported: those function keys are not supported by the current cy.press() API. Choose a supported interaction or test the relevant behavior by another means.
  • A named key value is unclear: use the available Cypress.Keyboard.Keys constant and consult the API reference for your installed version.
  • Focus does not move as expected: confirm the starting element can receive focus and that the application’s tab order or keyboard handler leads to the element you assert. Assert the actual expected state rather than assuming the event alone determines it.

Or skip the browser setup

If your task is to capture a page rather than test Cypress keyboard behavior, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns an image or PDF; see the API documentation.

Rank #4
Redragon K521 Upgrade Rainbow LED Gaming Keyboard, 104 Keys Wired Mechanical Feeling Keyboard with Multimedia Keys, One-Touch Backlit, Anti-Ghosting, Compatible with PC, Mac, PS4/5, Xbox
  • 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
  • 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
  • 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
  • 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
  • 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month—no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Can I pass a string such as “hello” to cy.press()?

No. It is for a single key interaction; use cy.type() to enter text.

Best Value
Sale
Logitech K270 Full Size Wireless Keyboard for Windows - Black
  • All-day Comfort: This USB keyboard creates a comfortable and familiar typing experience thanks to the deep-profile keys and standard full-size layout with all F-keys, number pad and arrow keys
  • Built to Last: The spill-proof (2) design and durable print characters keep you on track for years to come despite any on-the-job mishaps; it’s a reliable partner for your desk at home, or at work
  • Long-lasting Battery Life: A 24-month battery life (4) means you can go for 2 years without the hassle of changing batteries of your wireless full-size keyboard
  • Simply plug the USB receiver into a USB port on your desktop, laptop or netbook computer and start using the keyboard right away without any software installation
  • Simply Wireless: Forget about drop-outs and delays thanks to a strong, reliable wireless connection with up to 33 ft range (5); K270 is compatible with Windows 7, 8, 10 or later

Does cy.press() trigger Cypress’s open-mode shortcuts?

No. cy.press() dispatches a key event in a test; open-mode shortcuts control the Cypress app.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 3
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.34
SaleBestseller No. 5
Logitech K270 Full Size Wireless Keyboard for Windows - Black
Logitech K270 Full Size Wireless Keyboard for Windows - Black
Plastic parts in K270 include 38% certified post-consumer recycled plastic; Eight hot keys: For instant access to the Internet, e-mail, music volume and more
$21.48

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.