Keyboard commands

These commands trigger a keypress on the keyboard.

List of commands

Command Description
I.type
I.press
Press a key or a string of keys
I.pressEnter Press the Enter key
I.pressUp Press the ↑ key
I.pressDown Press the ↓ key
I.pressLeft Press the ← key
I.pressRight Press the → key
I.pressTab Press the Tab key

I.type / I.press

Press a key or a string of keys.

This will send keyboard inputs to the element in focus, or the page <body> if no element is focus.

I.press and I.type are exactly the same thing - we simply provided these two versions for whichever linguistic preference you have.

Usage

I.type(key)
I.press(key)

Parameters

Parameter Type Remarks
key string
array of strings
Key(s) to press

Examples

Text input

Note that I.fill(field, value) is recommended over I.type(value) for entering text into input fields

I.type("hello") // this will send "h" "e" "l" "l" "o"

Press a key

I.press("?") // this will send "?"

Press a special key

// Send a special keys 
I.press("Backspace") // This will press the "Backspace" key
I.press("Delete") // This will press the "Delete" key
I.pressEnter() // Convenience command are provided for frequently used keys

Press a chord (send multiple keys simultaneously)

// Send a chord (press multiple keys at the same time)
I.press(["Shift", "a"])
I.press(["Alt", "A"]) 
I.press(["Control", "A"])
I.press(["Meta", "A"])
I.press(["Shift", "Control", "A"])

I.pressEnter

Press the Enter key.

This is same as using the command I.press("Enter").

Usage

I.pressEnter()

I.pressUp

Press the ↑ key.

This is same as using the command I.press("ArrowUp").

Usage

I.pressUp()

I.pressDown

Press the ↓ key.

This is same as using the command I.press("ArrowDown").

Usage

I.pressDown()

I.pressLeft

Press the ← key.

This is same as using the command I.press("ArrowLeft").

Usage

I.pressLeft()

I.pressRight

Press the → key.

This is same as using the command I.press("ArrowRight").

Usage

I.pressRight()

I.pressTab

Press the → key.

This is same as using the command I.press("Tab").

Usage

I.pressTab()