How to add a set of keyboard shortcuts for document/text applications in System Preferences with Automator

applescriptkeyboard

I have a MacBook Pro that is using the 10.10.5 (Yosemite, the second one, I believe) operating system, and I want to change some "text"/"document" keyboard shortcuts for specific programs to have a unified shortcut functionality across all software I use.

System Preferences doesn't seem to have any way to change them, and I had called a technical support person at Apple to see if there was any way I could. There was not, and I simply continued to search online if there was ANY way they can be changed.

I came to a website, seeing someone wanting to add a new shortcut, for documents (not as simply as I would want, but…), using Automator. It is actually a big surprise what it can do!

I was wondering how may I add two keyboard shortcuts of the same thing, just different directions (they involve Ctrl+Up / Down arrows, doing what Cmd+Up / Down arrows do in text-type applications. Again, that is the thing I can not change in System Preferences | Keyboard Shortcuts.

I do not want to switch around Ctrl and Cmd as the other's modifier key for any type of text documents; the prominent ones I have that I simply use most are Notes, Pages, and Scrivener (I would think there can be an option for adding for all text-type applications, but that is why I'm asking, that I can know).

What would I select in Automator (the services document in it, as the start), and then what to type in to add those two commands (and I can answer what the commands are in more detail).

Those shortcuts will help me immensely, since I also do much writing and typing, and would like some uniform cursor-movement options.

Best Answer

Follow this guide from Apple about how to make a system-wide service in Automator.

The service will not require any input, but should be made available in any application.

Add a Run AppleScript action. Enter this code in the text box:

on run {input, parameters}

    tell application "System Events" to ¬
        return (key code 126 using command down) -- Command Up

end run

This is the AppleScript code that will simulate pressing +.

Save the service, naming it something like Command Up.

Finally, go into System Preferences and create a keyboard shortcut for this service. It will appear towards the bottom of the services list:

Service shortcuts in MacOS

Assign it the shortcut + (ctrl+up).

Now, when you press +, the system will issue an automatic + keypress, allowing you to hijack its function.

Now repeat the process for your other key combo. The AppleScript for that one, which will be simulating a +, is:

on run {input, parameters}

    tell application "System Events" to ¬
        return (key code 125 using command down) -- Command Down

end run