How do I program my Mac's F19 key to automatically type a text when I press it?
You could also create ~/Library/KeyBindings/ and save a property list like this as DefaultKeyBinding.dict.
Applications have to be reopened to apply changes. For more information, see http://www.hcs.harvard.edu/~jrus/Site/Cocoa%20Text%20System.html or http://lri.me/keybindings.html.
If you want to use any keyboard shortcut, with built-in methods …
Open up Automator.app and create a new Service. Set it to receive no input and drag Run AppleScript from the left pane to the right.
Enter this script:
Save the service under any name you like. Normally, you'd assign shortcuts to services by going to System Preferences » Keyboard » Keyboard Shortcuts. Here, you can assign (almost) any key combination.
However, in OS X 10.6, there's a bug that won't let you assign a service to an F-key. See the second option in my answer on how to overcome that. In 10.7 it seems to work though.
If you want to use third-party software …
Open up AppleScript Editor.app and paste the script from above. Save it under
Then, after you've saved the script, you can install FastScripts and bind that script to F19 (or whatever you like).