VLearnVibium

How to Press Keyboard Keys in Vibium

Press keyboard keys in Vibium with el.press() and page.keyboard. Runnable Python examples for Enter, Tab, and shortcuts like Control+A.

By Pramod Dutta··3 min read·Verified with Vibium 26.2
▶ Animated overview · made with Remotion

To press a keyboard key in Vibium, find the element and call press() with the key name, like vibe.find("#search").press("Enter"). Vibium focuses the element, waits for it to become actionable, then dispatches a key-down and key-up pair through WebDriver BiDi's input.performActions, so the keystroke is a genuine browser event rather than a simulated one. Key names follow the standard set — "Enter", "Tab", "Escape", "ArrowDown", "Backspace" — and combinations are written as one plus-joined string, for example press("Control+A") to select all or press("Control+Shift+K") for an app shortcut. For page-level input that does not target a specific element, the page.keyboard API offers press(), down(), up(), and type() so you can hold and release keys manually. Because Vibium auto-waits before the keystroke, you rarely need explicit waits to make a key press land on a freshly focused field.

How do I press a single key like Enter or Tab?

Locate the element with find(), then call press() with the key name. Vibium focuses the element first, so the key lands on the right target.

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com")
 
# Type a query, then submit it by pressing Enter
search = vibe.find("#search")
search.type("vibium")
search.press("Enter")
 
# Move focus to the next field with Tab
vibe.find("#first-name").press("Tab")
 
vibe.quit()

Pressing Enter in a search box submits the form the same way a user would, which is often cleaner than hunting for the submit button. Use Tab to move focus, Escape to dismiss a dialog, and the arrow keys to navigate menus or option lists.

How do I press a keyboard shortcut like Control+A?

Write the combination as a single string with each key joined by a plus sign. Vibium holds the modifier keys, presses the main key, then releases everything in order.

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com")
 
editor = vibe.find("#editor")
editor.click()
 
# Select all, then delete it
editor.press("Control+A")
editor.press("Delete")
 
# App-specific shortcut
editor.press("Control+Shift+K")
 
vibe.quit()

On macOS, swap Control for Meta where the app expects the Command key, for example press("Meta+A"). Combos work for any modifier — Control, Shift, Alt, and Meta — so you can reproduce save, copy, paste, and custom in-app shortcuts.

When should I use page.keyboard instead?

Use the page-level page.keyboard API when the input is not tied to one element — for example a global shortcut, or when you need to hold a key down across several actions. It exposes press(), down(), up(), and type().

# Press a key at the page level (whatever is focused receives it)
vibe.keyboard.press("Escape")
 
# Hold Shift while clicking to extend a selection
vibe.keyboard.down("Shift")
vibe.find(".item-5").click()
vibe.keyboard.up("Shift")
 
# Type a string of characters without targeting a specific element
vibe.keyboard.type("hello world")

For entering text into a known field, prefer typing into the element with el.type(), which focuses the field for you. Reach for el.press() to fire a single key on a specific element, and page.keyboard for page-wide or held-key input. See how to find elements in Vibium for locating the field first.

Next steps

Frequently asked questions

How do I press a key in Vibium?

Find the element and call press() with the key name, like vibe.find('#search').press('Enter'). Vibium focuses the element, waits for it to be actionable, then sends a key down and key up event through WebDriver BiDi, so the keystroke lands on the right field.

How do I press a keyboard shortcut like Control+A in Vibium?

Pass the combo as a single string joined with a plus sign, such as press('Control+A') or press('Control+Shift+K'). Vibium holds the modifier keys, presses the main key, then releases everything, reproducing a real shortcut press for select-all, save, and similar actions.

What is the difference between type and press in Vibium?

type() sends a string of characters into a field, while press() sends a single key or key combination such as Enter, Tab, Escape, or Control+A. Use type() to enter text and press() to trigger keys that submit forms, move focus, or run shortcuts.

Vibium is created by Jason Huggins. This is an independent tutorial — see the official Vibium site and GitHub repo for canonical docs.

Related guides