hubcap press

Press a key or key combination.

When to use

Press a key or key combination. Supports modifiers: Ctrl+, Alt+, Shift+, Meta+. Use type for text input instead. Named keys: Enter, Tab, Escape, Backspace, Delete, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown, Space.

Usage

hubcap press <key>

Arguments

ArgumentTypeRequiredDescription
keystringYesKey name or combination (e.g., Enter, Ctrl+a, Ctrl+Shift+n)

Flags

None.

Output

FieldTypeDescription
pressedbooleanWhether the key press succeeded
keystringThe key or combination that was pressed
{"pressed":true,"key":"Enter"}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Press Enter to submit a form:

hubcap press Enter

Select all text:

hubcap press Ctrl+a

Press Escape to close a dialog:

hubcap press Escape

Focus an input, select all existing text, then type a replacement:

hubcap focus '#email' && hubcap press Ctrl+a && hubcap type 'new@example.com'

See also

  • type - Type text keystroke by keystroke
  • fill - Clear and type into an input field
  • focus - Focus an element before pressing keys