In Keynote, is there any way to assign shortcut keys to select specific fonts?

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?


Solution 1:

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
        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.

Solution 2:

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:

image

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.

Solution 3:

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.