I'm writing a series of lectures where I use a different font to indicate code. Is there any way to assign new shortcut keys/key combinations to select the two fonts I want?

  • You should accept jm666's answer. It is excellent and I highly doubt you'll get a better one.
    – Cajunluke
    Sep 15, 2012 at 3:37
  • Also: if you use Eclipse as your IDE, it puts copied code onto the clipboard in rich text with the font you use in Eclipse and full syntax highlighting in addition to normal plain text.
    – Cajunluke
    Sep 15, 2012 at 3:39
  • @CajunLuke - it was a great answer, but it didn't work in practice. Another answer worked directly. Also, I have no idea what Eclipse is or why I'd be using it with Keynote.
    – keflavich
    Sep 17, 2012 at 0:03

3 Answers 3


I didn't find any way to modify the style of the selection, but you could use UI scripting to select a font from the format bar.

tell application "System Events" to tell process "Keynote"
    tell pop up button 1 of window 1
        click menu item "Menlo" of menu 1
    end tell
end tell

You could assign shortcuts to the scripts with FastScripts or by creating Automator services.

  • For me at least, it was pop up button 2 of window 1, but otherwise this works
    – keflavich
    Sep 17, 2012 at 0:01

I don't know any easy-simple way, but (as usual) Automator and scripting can provide some help.

The basic idea is:

  • You write the text with the Keynote's default font.
  • Select the text.
  • Press a hotkey - this will run the Automator script and replace the font for the selected text.

so, to make this work:

  1. Start Automator.
  2. Select the type "Service".
  3. At the top change "text" to "rich text" and set the checkbox "Output replaces…".
  4. From the Library in the left side drag into the right side the following actions. (You can use the search field to quickly locate the needed actions.)
    • "Copy to Clipboard"
    • "Run Shell Script" (and check the box "Ignore this action's input" in the action's Options)
    • "Get Contents of Clipboard"

into the "Run Shell Script" action enter:

pbpaste -Prefer rtf | textutil -stdin -convert rtf -font 'Menlo' -fontsize 32 -stdout | pbcopy

Replace the Menlo with your wanted font name and change the 32 to the needed size.

All the above is sounds complicated, but it is much faster to do it as reading the above. ;) Here's what your Automator screen should look like when you're done with the above steps:


Save and name the service, for example, as "SetMyFont". Now you have a new "Service", so let's check it out:

  • Start Keynote (or TextEdit or whatever program you'll want to use this Service in).
  • Select some text that you want to change the font of.
  • Go to menu: Keynote -> Services and select your previously named service, e.g. "SetMyFont".
  • Your selected text should now appear in the new font.

If the service works, you now should add a global hotkey for it:

  • Go to System Preferences -> Keyboard -> Keyboard Shortcuts.
  • In the "Services" tab, search for your service name, e.g. "SetMyFont". It should be in the "Text" group.
  • Select the checkbox and add a shortcut. (see screenshot)

enter image description here

  • And you're done!

A bit complicated to set up, but it works and when you have lots of text, it can speed up the formatting a bit.

(Somebody will likely suggest much simpler solution using AppleScript directly with Keynote.)

When you've finished the work and don't need the service anymore, you can remove the "SetMyFont.workflow" from the ~/Library/Services, or uncheck that checkbox in the Keyboard preference pane.

  • Why need to use the clipboard in the workflow and not uses stdin/stdout directly?
    – cajwine
    Sep 7, 2012 at 22:29
  • 1
    Because for some (not very clear) apple's reason the "Shell script" action accepts (and produces) only "plain text" and not "rtf". Therefore need pass rtf to/from the shell-script via clipboard and pbcopy/pbpaste.
    – clt60
    Sep 7, 2012 at 22:33
  • 1
    I got it to work on 10.7, but it also changes the font color. Is there any way to preserve all OTHER text properties, and ONLY change the font?
    – keflavich
    Sep 8, 2012 at 18:41
  • 1
    Unfortunately don't know any solution what preserving any formatting. What is possible to do, get the text and set some basic formatting properties - like, size, font-name. With a small modification is possible setup the color too, but you need to know the color RDB code or name.
    – clt60
    Sep 9, 2012 at 17:03
  • 1
    pbpaste and pbcopy don't preserve Unicode characters in Automator's default environment. You could fix that by adding export LC_CTYPE=UTF-8; to the start. (Terminal and iTerm set LC_CTYPE to UTF-8 by default.)
    – Lri
    Sep 15, 2012 at 5:01

Not by default, but according to Apple's Keynote shortcut page you can use:

Copy paragraph style Option-Command-C

Paste paragraph style Option-Command-V

Better than nothing, I hope.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .