Cypress Type Command Modifier Effects

Cypress Type Command Modifier Effects

If we forget what modifiers the sequence we pass inside the type command in cypress like alt, ctrl, meta, and shift are called modifiers. They activate the key simulation modifier. So about modifier effects, In the honest browser, if a particular individual holds down SHIFT and types the letter 'a', a capital 'A' will appear as input.

Cypress cannot simulate this behavior as of now. Modifiers are simulated here by setting their values true for key and click events. If there is a need for activating the {alt} modifier, this will set the event.altkey to true for any key event such as key down.

  • This command will type in a capital 'A' because of the shift+a modifier effect.
  • .type('{shift}a') will type in caps 'A' or if we dont care about any shiftkey property to interfere with this simply .type('{A') will suffice.
  • For an OSX, ALT + SHIFT + K creates a unique character, and if we use the same method on mac, it won't return the unique character, simply the letter 'k.'

Modifiers won't affect arrow keys or deletion keys like, for example, {ctrl}{backspace} won't delete an entire word.
So these are the effects of modifiers in cypress.

Standard (Image)