How to define Lion’s key variations in a `.keylayout` file?

In Lion you can hold down a key to show its variations.

Screenshot

However, when using my custom keyboard layout in .keylayout format, this functionality is disabled.

I assume Lion’s default keyboard layouts have the special characters that appear when you hold down a certain key hardcoded somewhere, and my old custom keyboard layout (based on the default Snow Leopard-layouts) lacks that data.

My question is: how can these “key variations” be defined in a .keylayout file?


The special characters included in the popovers are defined in files like /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en_US.plist, not in .keylayout files. (The popovers are also used with languages that have their own input methods like Vietnamese.)

I don't know how to add a property list like that for a custom layout though. I also tried copying the U.S..keylayout that comes with Ukelele to ~/Libary/Keyboard Layouts/ (without changing the name or id), but the popovers didn't work with it.


Ukelele.app 2.2 now supports this, kind of:

By saving a keyboard layout in a bundle, it will become compatible with the “press and hold” mechanism for entering diacritics, introduced in OS X 10.7 (Lion). For this purpose, an “intended language” can be supplied (default is the system language), which will determine which possibilities are offered in the pop-up. However, such bundles may not work with OS X 10.4 (Tiger) and earlier.