How to Add Abbreviations in AutoKey

Updated

To add an abbreviation in AutoKey, you create a new text-type entry in a folder and assign it an abbreviation as its trigger; when you later type that abbreviation and press a word boundary key, AutoKey replaces it with the entry's content. The AutoKey 0.96.0 documentation lists "Adding Abbreviations" under Common actions, and the API reference documents the keyboard and clipboard machinery that performs the substitution. The exact menu path and dialog fields are not reproduced in the documentation excerpt, so follow the labels in your installed version.

What an abbreviation does

An abbreviation is a short trigger string tied to a longer piece of text. AutoKey watches what you type and, when the trigger is matched, substitutes the configured content. This is the same mechanism behind the "some examples" the documentation introduces on its welcome page.

Two practical consequences follow:

  • The trigger must be unambiguous. If your abbreviation is a string you also type normally, it will fire when you don't want it to. Choose something you would not otherwise type, or one that ends in a character you rarely use.
  • The match happens on typing, not on a hotkey. Unlike a script bound to a keyboard shortcut, an abbreviation needs no key combination — you just type it.

Steps to create one

  1. Open the AutoKey main window and select the folder that should hold the abbreviation. Folders keep related entries together; the documentation's "How are things organized?" section explains this structure.
  2. Create a new entry of the text type. In AutoKey, abbreviations are a kind of text entry — the content you supply is what gets inserted.
  3. Set the abbreviation field to your trigger string. This is the text AutoKey will watch for.
  4. Set the contents field to the replacement text — the phrase, signature, snippet, or code fragment you want inserted.
  5. Save the entry. The abbreviation becomes active for the folders/phrases currently enabled in AutoKey.
  6. Test it in a plain text editor: type the trigger, then a space or other word-ending key, and confirm the replacement appears.

If nothing happens, check that the phrase folder containing the entry is enabled and that AutoKey itself is running — an entry in a disabled folder will not trigger.

How the substitution is performed

The API reference shows the machinery AutoKey uses to insert text. Keyboard.send_keys() sends a string as keystrokes, while Keyboard.SendMode selects the delivery method:

Send mode What it does
KEYBOARD Types the text as individual key events
CB_CTRL_V Pastes via Ctrl+V
CB_CTRL_SHIFT_V Pastes via Ctrl+Shift+V
CB_SHIFT_INSERT Pastes via Shift+Insert
SELECTION Uses the current selection mechanism

This matters when an abbreviation misbehaves in a particular application. Some programs ignore synthetic keystrokes but accept a clipboard paste, so switching the send mode is the usual fix for an expansion that types nothing or types only part of the text. The Keyboard API also exposes fake_keypress(), press_key(), release_key(), send_key(), wait_for_keyevent(), and wait_for_keypress() for finer control, and the Key constants (for example Key.ENTER, Key.TAB, Key.BACKSPACE) let a script send the boundary key that completes a trigger.

Where abbreviations live and how matching works

Abbreviations are stored as entries inside phrase folders, and the folder structure is what the documentation's "How are things organized?" section describes. Matching is against the text you type in the focused application; the trigger fires when the typed sequence matches an active entry. Because the trigger is plain typed text, the same abbreviation can be used across applications — but it also means a trigger that collides with ordinary typing will fire unexpectedly, which is why distinctive triggers are worth the extra keystrokes.

Related actions worth knowing

The documentation groups abbreviations with other common actions, and the API reference covers the surrounding capabilities:

  • Keyboard control — Keyboard.send_keys() and the send modes above, plus the Key constants for special keys.
  • Mouse control — the Mouse API (click_absolute(), click_relative(), move_cursor(), select_area(), wait_for_click(), and others) for entries that need to click or select rather than just type.
  • Persistent values — the Store API (get_value(), set_value(), get_global_value(), set_global_value(), has_key(), remove_value(), remove_global_value()) for entries that remember state between triggers.
  • Dialogs — the QtDialog API, including calendar() and choose_* methods, for entries that prompt for input.

For a first abbreviation, the text-entry route above is enough; reach for the API when the expansion needs to press special keys, paste into an application that rejects synthetic typing, or vary its output based on stored values.