cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Keys can be "held" across commands

Open cacieprins opened this issue 3 weeks ago • 0 comments

What would you like?

I would like to issue a "keydown" event, execute one or more Cypress commands, and then issue a "keyup" event.

Implementation/Signature TBD. Some options include:

Options object:

cy.press(Cypress.Keyboard.SHIFT, { release: false }) // keydown
cy.hold(Cypress.Keyboard.META) // keydown
cy.press(Cypress.Keyboard.SHIFT, { release: true }) // keyup
cy.press({ release: true }) // issues a keyup event for all currently held keys

Discrete commands:

cy.hold(Cypress.Keyboard.SHIFT) // keydown
cy.hold(Cypress.Keyboard.META) // keydown
cy.release(Cypress.Keyboard.SHIFT) // keyup
cy.release() // issues a keyup event for all currently held keys

When a test ends, all "held" key state is cleared.

Open questions:

  • When a navigation occurs, do we re-issue keydown events - or consider all held keys released?

Why is this needed?

No response

Other

No response

cacieprins avatar Feb 07 '25 17:02 cacieprins