cypress
cypress copied to clipboard
Key modifiers can be applied to cy.press command invocations
What would you like?
I would like to be able to chord alt
, command
, control
, meta
, and/or shift
keys with the cy.press
command.
Acceptance Criteria
- I can indicate that
cy.press
should "hold"alt
,command
,control
,meta
, and/orshift
keys while pressing the primary special key press. - The key sequence should be: keydown of
...modifiers
, keydown ofpress
key, keyup ofpress
key, keyup of...modifiers
in reverse order. Such that CTRL+SHIFT+TAB would issue the following events:- keydown CTRL
- keydown SHIFT
- keydown TAB
- keyup TAB
- keyup SHIFT
- keyup CTRL
Signature
TBD. Some potential approaches.
Combined Array
cy.press([
Cypress.Keyboard.Keys.SHIFT,
Cypress.Keyboard.Keys.TAB
])
This introduces ambiguity between modifier keys and "command" type keys, however. This ambiguity makes parameter validation more complicated, and the command less explicit.
"Options" parameter as a series of flags
cy.press(Cypress.Keyboard.Keys.TAB, {
shift: true
})
This separates the modifier keys from the primary action key explicitly which makes validation easier, but the order of keypresses is indeterminate. The order that modifiers keys are pressed may be important.
"Options" parameter as an Array
cy.press(Cypress.Keyboard.Keys.TAB, {
modifiers: [Cypress.Keyboard.Keys.SHIFT]
})
This keeps the modifier keys separate from the primary action key like the series of flags, but allows for defining an order of operations: we would issue keydown events for the modifier keys in the order that they are defined in the array, the action keydown and keyup, followed by the modifier keys in reverse order.
Why is this needed?
No response
Other
No response