Text expansion

How text expansion works on macOS

Updated · Applies to macOS 14 Sonoma through macOS 27 Golden Gate

Short answer

A text expander listens to keystrokes through a macOS event tap (which needs Accessibility permission), notices when the last few characters match an abbreviation, deletes them, and inserts the expansion, usually by pasting it and then restoring your clipboard.

If you’re about to give an app permission to see your keystrokes, it’s reasonable to want to know what it does with them. Here’s how text expansion works on a Mac, and what a well-behaved expander should and shouldn’t do.

1. Listening for keystrokes

macOS lets an app install an event tap: a hook that sees keyboard events as they’re delivered. Because that’s powerful, macOS only allows it once you grant the app Accessibility access in System Settings → Privacy & Security. A tap can be listen-only, meaning it sees keys but can’t change or block them, which is all an expander needs.

A careful expander keeps only a small rolling buffer of the last few characters, in memory, and forgets it whenever you click, switch apps, or move the cursor. There’s no reason for it to store what you type.

2. Matching abbreviations

After each key, the expander checks whether the end of the buffer matches one of your abbreviations. That’s why abbreviations that start with an unusual character (;sig) are safer than plain words. It’s also why one abbreviation can block another: if ;ad exists, ;addr can never be typed, because ;ad fires first. Good expanders warn you about these clashes.

3. Inserting the expansion

There are two ways to put text into another app, and each has trade-offs:

4. Staying out of password fields

When you’re in a password field, macOS turns on secure input, which stops event taps from seeing keystrokes at all. Expanders should also check for secure input themselves and let you exclude apps entirely, such as password managers.

5. Placeholders

Before inserting, an expander can fill in placeholders: today’s date, a date three days from now, your clipboard, another snippet, or fields you fill in from a small panel. It can also note where the cursor should end up and move it there after pasting.

What to look for

Ready to choose one? See choosing a text expander for Mac.