Skip to main content

Simulating Keys

Snippety allows you to simulate key presses in the snippet. This is useful if you want to automate repetitive tasks or if you want to create a snippet that interacts with the system.

You can simulate any key press, including special keys like Enter, Tab, or Arrow Down. You can also combine multiple keys, for example, CMD + A.

Adding Simulated Key

To add a simulated key, press Simulate Keys button in the snippet editor. In the pop-up window, you can record the key you want to simulate and configure the delay after the key press and the number of repetitions.

You can also use the CMD + K shortcut to open the pop-up window.

Simulate Keys

Filling Forms

You can use simulated keys to fill forms. For example, you can create a snippet that fills a form on a website. You can use the Tab key to navigate between fields and the Enter key to submit the form.

Here is a sample snippet that fills a form with the name and address:

John
{@key|⇥|0.1|1@}
Snow
{@key|⇥|0.1|1@}
Wall Street
{@key|↩|0.1|1@}

Creative Usage

You can use simulated keys to automate repetitive tasks. For example, you can create a snippet that opens a new tab in the browser, navigates to a specific website, and fills the form.

You can also use simulated keys to interact with the system. For example, you can create a snippet that opens the terminal, runs a command, and copies the output to the clipboard.

Another example is a snippet that automatically sends an email with the selected text as the body.

In general, anything that you can achieve by pressing keys on the keyboard can be automated with simulated keys. So pay attention to your daily workflow and think about how you can automate repetitive tasks with Snippety.

Whitespaces

By default Snippety removes whitespaces around simulated keys. This is useful to improve the readability of the snippet. For example, this snippet:

John
{@key|⇥|0.1|1@}
Snow
{@key|⇥|0.1|1@}
Wall Street
{@key|↩|0.1|1@}

will be expanded to:

John<TAB>Snow<TAB>Wall Street<ENTER>

However, if you want to preserve the whitespaces, you can disable this behavior in App Settings -> Behaviors. This option is called Remove whitespaces around simulated keys.

If you disable this option, the snippet will be expanded to:

John<NEWLINE><TAB><NEWLINE>Snow<NEWLINE><TAB><NEWLINE>Wall Street<NEWLINE><ENTER>

To achieve the same effect as before with disabled option, you would need to create the snippet like this:

John{@key|⇥|0.1|1@}Snow{@key|⇥|0.1|1@}Wall Street{@key|↩|0.1|1@}

which is less readable.

Placeholder

See the Simulated Key placeholder for more information about the parameters and syntax.