Keyboard Action

The Keyboard Action block presses keys on the keyboard: a single key like Enter, Tab, or Escape, or a shortcut like Ctrl/CMD C keystroke combination goes to whatever is currently focused on the active web page.
How To Use It

Click into the field ("Press a key on your keyboard") and press the key or combination you want to send on your keyboard. It's captured as you press it and shown back, for example Shift Tab or Ctrl C .
Click the Save button to close this block's configuration and release keyboard control back to you.
Block-level Delays
Min sec and Max sec represent a pause after the keys are pressed, before the next block runs. The wait is randomized between the two values, and setting both to the same number makes it fixed. This block defaults to 1 second.
Things To Know
Focus first because keystrokes go to whatever web page element is active. This block doesn't allow you to specify a CSS selector or XPath, so the keystrokes hit wherever the cursor already is, or whatever element you're already focused on. First click into a field with a Click Web Element block, or insert text with an Insert Text or Data block, or change the focused page element with a Tab into it before pressing keys with this block. Without doing so, the keypresses within this block may land nowhere useful.
bodyis a valid selector; handy for focusing the whole web page before using this block. Some keys act on the page rather than a field, like PageUp / PageDown, or Space to scroll. If you need to use this block to operate on a page, consider using a Click Web Element block withbodyas its CSS selector prior to it.CMD and Ctrl adapt to the operating system your TaskBot runs on. Keyboard shortcuts you set with CMD on a Mac automatically work when your TaskBot runs on Windows or Linux; ZeroWork automatically maps CMD and Ctrl to each other so they match the operating system your TaskBot is running on. You don't need separate versions per environment or OS.
One block can run a whole keyboard sequence. The keys play in the order you press them, so a single block can repeat a key. For example, Tab Tab Tab moves through 3 form fields or web page focusable elements. If you're working with many same repeatable keypresses, consider wrapping this block in a Start Repeat loop instead of capturing the key over and over within a single Keyboard Action block; you don't need a Keyboard Action block that contains 42 Tab keypresses if you have one Start Repeat block before this one that simply uses a fixed number of 42 iterations.
A modifier key stays held for the rest of the block and doesn't let go mid-sequence. ZeroWork lets you shortcut your keyboard shortcuts because every key after a modifier key like CMD (or Ctrl) is combined with it. For example, CMD A C in this block will do 2 things at once: select all, then copy that selection to your machine's clipboard. This also means that keys you might have meant to press plain (without a modifier) still carry the modifier you used, (for example CMD A X selects all and then cuts to the clipboard instead of typing the "x" character). When you need an unmodified key after already using a previous modifier key in this block, or when you need to use another keyboard shortcut that uses a different modifier key than you used earlier in this block, start a new Keyboard Action block.
Web Page Keyboard Shortcuts
Keys that work inside the page (what's actively focused decides what they do):
Tab or Shift Tab
Move focus to the next / previous field, link, or button
Enter
Submit a form, or activate the focused link or button
Space
Toggle a focused checkbox or press a focused button, or scroll down a screen when the page itself is focused (Shift Space also scrolls up)
Escape
Close a pop-up, modal, dropdown, or autocomplete list on most websites
Home
Jump to the top of the page, or the start of the line when a text field is focused
End
Jump to the bottom of the page, or the end of the line when a text field is focused
PageUp
Scroll up one screen
PageDown
Scroll down one screen
CMD/Ctrl A
Select all the text in the focused field, or page if it's focused
CMD/Ctrl C
Copy the current selection to the clipboard
CMD/Ctrl X
Cut the current selection to the clipboard
CMD/Ctrl V
Paste clipboard content into the focused field
CMD/Ctrl R
Refreshes or reloads an active web page. This is the only browser-level keyboard shortcut that ZeroWork automatically handles
Browser-level Keyboard Shortcuts
More broadly, any shortcut that controls the browser itself or your computer (new windows, zoom, bookmarks, devtools, the address bar, or OS shortcuts) won't reach the browser's active page, so it does nothing here.
Block Behavior
When keys are set the block sends them to the focused element on the active web page, playing them in the order they were captured, and logs the keys it pressed.
When a shortcut uses a modifier the modifier stays held for every key after it until the block ends, so each following key combines with it.
When the shortcut is CMD/Ctrl R (optionally with Shift) the block reloads the active web page instead of sending the keystroke, and logs that it reloaded the page.
When the TaskBot's operating system differs from the one the keys were set on CMD and Ctrl are swapped so the shortcut matches the operating system the TaskBot is running on.
When no keys are set the block fails, reporting that no keys were provided.
When a key can't be pressed (an unknown or unsupported key) the block fails, reporting that it can't press that key.
FAQ
Can I copy and paste with CMD/Ctrl C and CMD/Ctrl V? Yes. This block sends a real keypress to the page, so the browser's own copy, cut, paste, and select-all all work as you expect: CMD/Ctrl A to select all, CMD/Ctrl C to copy (or CMD/Ctrl X to cut), and CMD/Ctrl V to paste into the focused field. Copying needs something selected (often a CMD/Ctrl A in the block right before), and pasting needs the target field focused. Once text is on the clipboard, a Save From Clipboard block can pull it into a ZeroWork variable.
The exception is browser-window shortcuts; ones like CMD/Ctrl P (print), CMD/Ctrl F (find or search bar), and CMD/Ctrl S (save page) act on the browser window itself rather than the web page inside that browser window, so this block doesn't open them. CMD/Ctrl R is handled specially by ZeroWork and reloads the page.
Can you give me a keyboard shortcut for a specific web app I'm automating? Facebook shortcuts Slack shortcuts Instagram shortcuts
Video Tutorial
Last updated