I have a text phrase (actually, several phases) that I use frequently in multiple applications. I'd like to create a keyboard shortcut or hotkey that will paste this text phrase wherever I have placed my cursor in a text input field (Apple Mail, Microsoft Word, TextEdit, TextWrangler, browser windows, etc.) rather than constantly copying and pasting from a sticky note.

I'd prefer not to have to buy any apps (seems like Keyboard Maestro has this functionality but seems silly to pay $36 just for this), though free apps would be fine. Tried looking under System Preferences > Keyboard > Keyboard Shortcuts but no obvious solution, and all AppleScripts I found seem to not translate properly for me. I've found other solutions for this problem on this forum for Windows users (like AutoHotKey) but none for Mac users.


The easiest way to type text with an AppleScript is to run:

tell application "System Events" to keystroke "foo bar"

You can trigger this with a keyboard shortcut by creating a new Quick Action (previously called Service) in Automator. Set it to receive No Input, and then drag Run AppleScript from the left pane to the right.

It should look like this:

Save it, and then assign a keyboard shortcut to this Service under System Preferences » Keyboard » Keyboard Shortcuts.

  • Wow, thanks so much @slhck! I tried this, but am having problems in the last step. It's not showing up in the "Services" menu when I go to "Keyboard Shortcuts" in System Preferences. I know it runs because when I open Automator and hit Play, the text is typed in the previous application, but it won't show up in service so I can add a keyboard shortcut even though I have saved it in my Library > Services folder. On the advice of other forums I Googled, I double-checked that the service input was set to "Service receives: no input" (it was) and tried relaunching the Finder. Any thoughts? – Ruthie Jan 30 '13 at 0:56
  • So you saved it from Automator? Normally it should appear in the Keyboard Shortcuts options, under Services and General at the bottom. Have you tried logging out and back in, or even restarting? – slhck Jan 30 '13 at 8:06
  • @slhck this sounds like a great way to do this, but could you detail your answer a bit more? I'm not fluent with the way Automator works, when I launch it it asks me "chose a type for your document" and then I'm kind of lost. I'll go with Jonathan Huie's answer for now but it still implies typing something... Thanks! – MicroMachine Oct 17 '15 at 23:38
  • @fabriced You need to create a Service in Automator. – slhck Oct 19 '15 at 8:50
  • 2
    I find that this works in a text editor, but not in a text field on a website. Anyone else? – Eliot Oct 23 '15 at 18:51

The keystroke command can only be used to insert characters that are found on the current keyboard layout, and there is a visible delay for long strings of text. You can also insert text directly:

That method isn't really usable either. There is a bug on 10.7 and 10.8 where the shortcuts for Automator services don't always work until you hover over the services menu.

I have used FastScripts to assign this script to F3:

    set old to the clipboard as record
end try
    tell application "System Events"
        key code 123 using {option down, shift down}
        keystroke "c" using command down
    end tell
    delay 0.05
    set input to the clipboard
    read POSIX file "/Users/lauri/Notes/snippets.txt" as «class utf8» using delimiter linefeed
    repeat with p in result
        considering case
            if p starts with (input & " ") then
                set the clipboard to text ((offset of space in p) + 1) thru -1 of p
                tell application "System Events" to keystroke "v" using command down
                delay 0.05
                exit repeat
            end if
        end considering
    end repeat
end try
    set the clipboard to old
end try

snippets.txt look like this:

m name@example.com
cmd ⌘

Another option is to use DefaultKeyBinding.dict. This would make ⌥M or ⌥X and m insert an email address:

    "~m" = (insertText:, "name@example.com");
    "~x" = {
        "m" = ("insertText:", "name@example.com");

You can also add custom text to the popovers shown when holding keys. See this question.


Have a look for an App called "Textexpander" which gives you the abillity to define textphrases like @dd which - when typed - will be expandet to the defined content - in that case the actual date.

AFAIK it's Shareware. So it's not actually free but the demo mode is not timelimited.

  • Just a quick note in case it's useful for others -- TextExpander doesn't work on X11 terminal windows. – ggkmath Jul 8 '13 at 15:21

Just click on: System Preferences, Keyboard, Text, and enter your shortcut and phrase

  • 1
    I like this answer, but it does't really allow "keyboard shortcut" or "hotkey", one still has to input a text (and not a combination of keys) that gets replaced by the machine. – MicroMachine Oct 17 '15 at 23:29
  • 1
    This only seems to work in a few select apps. It does not work in most of the places I'd like it, eg browser input fields, my mail client (Thunderbird), Terminal, etc. – Don't Panic Sep 3 '17 at 10:14
  • Does this work? I have tried typing the "replace" string in the browser, text editor, and terminal, which are the only three places I'm ever typing in: none of them worked! – PatrickT May 23 '20 at 23:53
  • This is exactly what I was looking for. – malik bagwala Mar 31 at 4:49

Alfred app lets you do this—plus a great deal of other things—using the Workflow and Snippets features. I use Alfred all the time and highly recommend it. To unlock Workflows you have to pay for a Powerpack license, but you won't regret it. 😉

  • I agree, this is one of the most useful apps anyone owning a Mac should have. I fully migrated from custom Automator services to Alfred. – slhck Jul 12 '19 at 18:39

A separate keyboard called the Martian Keyboard will hold text strings such as sentences and even short paragraphs. It will save you from typing annoying nuisance keystrokes you type over and over, day after day. The keys are work like "paste" keys. It has the ability to store all the shortcuts in Word on a single keyboard, using shift layer keys. It's mainly for professional use, so it is a bit expensive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.