2 of 4 fixed markdown code block

You can do this without extra software by using Automator and the OS X Services functionality.

The Keyboard Viewer "app" lives at /System/Library/Input Methods/KeyboardViewer.app (in versions prior to Lion, it may be at /System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/KeyboardViewerServer.app). You open it with a hotkey by using Automator to create a simple launcher service.

  1. Open Automator and select Service as the type of your new document.
  2. Set the options (at the top of the workflow area) to "Service receives no input in any application".
  3. Add the Run Shell Script action to your workflow, and replace the text with the following lines:

    killall KeyboardViewer
    open "/System/Library/Input Methods/KeyboardViewer.app"
  4. Save with a name like "Open Keyboard Viewer", then open Keyboard Preferences to the Keyboard Shortcuts tab. Select Services in the left pane and scroll to the bottom, where you should see the name of your Service under the General Section.
  5. Make sure the box is checked to enable it, then select it and click add shortcut to set a hotkey.
  6. After setting the hotkey, open the Services menu in any application (i.e. Finder > Services), then close it. For some reason my hot key didn't work until I did this.

A couple notes:

  • The killall KeyboardViewer line is there because closing the Viewer window doesn't quit the process, so if you open it, close it, then try to open it again, it won't return to view. You first have to quit the process then open.
    • The script is pretty dumb, so the KeyboardViewer process will remain open once you've launched it.
  • If you're running a pre-Lion OS, replace that path with the one to KeyboardViewerServer.app (check in Finder first), and replace KeyboardViewer with KeyboardViewerServer in the killall line.