How do I make keyboard viewer to automatically show up only when I'm holding the option key?
You could use a private.xml like this with KeyRemap4MacBook:

&lt;root&gt;
  &lt;vkopenurldef&gt;
    &lt;name&gt;KeyCode::VK_OPEN_URL_KEYBOARDVIEWER&lt;/name&gt;
    &lt;url&gt;file:///System/Library/Input%20Methods/KeyboardViewer.app&lt;/url&gt;
  &lt;/vkopenurldef&gt;
  &lt;vkopenurldef&gt;
    &lt;name&gt;KeyCode::VK_OPEN_URL_QUITKEYBOARDVIEWER&lt;/name&gt;
    &lt;url&gt;file:///Applications/QuitKeyboardViewer.app&lt;/url&gt;
  &lt;/vkopenurldef&gt;
  &lt;item&gt;
    &lt;name&gt;test&lt;/name&gt;
    &lt;identifier&gt;test&lt;/identifier&gt;
    &lt;autogen&gt;
    __KeyToKey__ KeyCode::OPTION_L,
    ModifierFlag::OPTION_L | ModifierFlag::NONE,
    KeyCode::OPTION_L,
    Option::KEYTOKEY_BEFORE_KEYDOWN,
    KeyCode::VK_OPEN_URL_KEYBOARDVIEWER,
    Option::KEYTOKEY_AFTER_KEYUP,
    KeyCode::VK_OPEN_URL_QUITKEYBOARDVIEWER
    &lt;/autogen&gt;
    &lt;autogen&gt;
    __KeyToKey__ KeyCode::OPTION_R,
    ModifierFlag::OPTION_R | ModifierFlag::NONE,
    KeyCode::OPTION_R,
    Option::KEYTOKEY_BEFORE_KEYDOWN,
    KeyCode::VK_OPEN_URL_KEYBOARDVIEWER,
    Option::KEYTOKEY_AFTER_KEYUP,
    KeyCode::VK_OPEN_URL_QUITKEYBOARDVIEWER
    &lt;/autogen&gt;
  &lt;/item&gt;
&lt;/root&gt;


Save this script as /Applications/QuitKeyboardViewer.app in AppleScript Editor:

quit application "KeyboardViewer"


There is a noticeable (but not that long) delay before KeyboardViewer is opened or closed. If for example you hold option and command simultaneously, KeyboardViewer is shown if you press option first but not if you press command first.