Thursday, June 28, 2012

OSX keyboard macros

OSX doesn't exactly come with keyboard macros, but it's not difficult to create them.  First, write an AppleScript that simply writes keystrokes to "System Events":
Save it to your "Library/Scripts" folder.

Then, add the key mapping you want to "System Preferences, Keyboard, Keyboard Shortcuts, Application Shortcuts".  Click the '+' to add one, use the name of the script you created, and choose a shortcut.  If you want to change the shortcut later, double click right over the characters for the shortcut.

I used this to create a shortcut when editing an html pre element, so it looks similar to

No comments: