0

I'd like keyboard viewer to show up while I hold the option key or after pressing a "dead key" such as option-e, but to hide otherwise.

I know where the letters are. But it would be nice to get an automatic reminder of how to type special characters, especially since my keyboard layout (known as "qwpr") allows typing hundreds of special glyphs.

1

You could use a private.xml like this with KeyRemap4MacBook:

<root>
  <vkopenurldef>
    <name>KeyCode::VK_OPEN_URL_KEYBOARDVIEWER</name>
    <url>file:///System/Library/Input%20Methods/KeyboardViewer.app</url>
  </vkopenurldef>
  <vkopenurldef>
    <name>KeyCode::VK_OPEN_URL_QUITKEYBOARDVIEWER</name>
    <url>file:///Applications/QuitKeyboardViewer.app</url>
  </vkopenurldef>
  <item>
    <name>test</name>
    <identifier>test</identifier>
    <autogen>
    __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
    </autogen>
    <autogen>
    __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
    </autogen>
  </item>
</root>

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.

2
  • Great answer. However, it doesn't cover the case of dead keys. I guess that for dead keys, I'd have two options: 1. combine something like your answer with an automator script which showed keyboard viewer for a set amount of time. 2. just use your solution once for each dead key, and tap option to hide kv once I'm done. Sep 17 '13 at 13:23
  • Wait, no... this gets in the way of typing, especially when combined with dead keys. In fact, every time you release the option key (if it was the first modifier you pressed) you lose your current dead key state; that's unacceptable, as dead keys use option, and the whole point is to make dead key glyphs more, not less, accessible. I've mucked around with using different applescript tricks, including accessing the menu item, the KV close or minimize button, or the killall command from the shell, and nothing works without problems so far. The closest is killall, which works but only once. Sep 18 '13 at 4:16

You must log in to answer this question.

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