Toggle Keyboard Viewer

Most OS X folk are probably aware that they can track down those special keycodes for things like £, ¢, etc. by looking at the keyboard layout in the Keyboard Viewer Palette. If you don’t know, you go to the “International” System Preference and in the “Input” pane, check the “Keyboard Viewer” box and close the window. A new menu bar item will appear on the right where you can select “Show Keyboard Viewer”.

I have quite a few menu bar items up already, so I don’t like this route - it uses up too much menu bar space. Instead, I use this script to see it (without losing any menu bar length)

tell application "System Events"
if exists process "KeyboardViewerServer" then
do shell script "killall KeyboardViewerServer"
else
tell application "KeyboardViewerServer" to activate
end if
end tell

It is worth mentioning that in Tiger, closing the Keyboard pallet kills the KeyboardViewerServer, but apparently this isn’t so in Panther, where once invoked, the KeyboardViewerServer remains running unless killed from the Activity Monitor, hence the “killall” instruction. In Panther, this script will require 2 hits if you close the window rather than using the script to quit.

With no way to test it on a machine running Panther, while a test for the window works, I haven’t pursued it because in Tiger, closing the window quits the process so I can’t test for the existance of one without the other.

exists process "KeyboardViewerServer" and not exists (process "KeyboardViewerServer")'s window 1

For reference:

/System/Library/Components/KeyboardViewer.component
/Contents/SharedSupport/KeyboardViewerServer.app

Thanks, Bruce;

Great to have sources and resources to fall back on - I never think to look for them.

A