Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

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

share|improve this answer
    
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. –  Jameson Quinn 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. –  Jameson Quinn Sep 18 '13 at 4:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.