Skip to main content

Cypress Keyboard API

The Keyboard API allows us to set the default values on how the type() command is executed.



Arguments - Options

  • keystrokeDelay: The default time in milliseconds is 10, and we can increase this value so that the delay can be observed while the type command executed. Value 0 removes the delay, and note that, it must be a non-negative number.

Set the Keystroke Delay in Index.js

A great place to put the keystroke configuration is in our cypress/support/index.js file since it is loaded before any test files get executed. Plus, it is pretty convenient and neat rather than using the syntax every time in the test code.

  keystrokeDelay: 20,

Remove 20 and set it to zero if you want to remove the keystroke delay.

  keystrokeDelay: 0,

Set the Keystroke Delay in Index.JS

That's it. We are done now. Every time the type command is executed, the keystroke in the input field is according to the delay time in milliseconds we provided in the index.js file.

Set Keystroke Delay in Describe and It

The other way is to use the keystroke delay in every test Configuration.

  • If you will specify Key stroke delay inside it, keystroke delay will be applied to all typing in this test
  • and by specifying key stroke delay in describe , you can add or removes keystroke delay in all tests in the describe suite.
describe('The Key combinations',() => {
    it('visit the site, perform various clicks', { keystrokeDelay: 0 },()=>{

Video Tutorial: Cypress Keyboard API

Submitted by arilio666 on April 6, 2022

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.