Go to page:

Search help:

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

Mac /

LyXmodifierKeys

Categories: Mac

Swapping the Command and Control keys for LyX on the Mac

The Problem

Early versions of LyX on Mac used to come with a graphical user interface called xforms, which required an X Window server (X11) to be running and lacked the Aqua-like look-and-feel that is now attainable through the Qt interface. However, the Qt libraries with which current versions of LyX/Mac are built put severe constraints on users' ability to customize the modifier key bindings.

Modifier keys are important for users relying heavily on keyboard shortcuts in LyX. The official binaries for LyX/Mac available from the main download page follow Qt's use of "Option" and "Command" (Apple) as modifier keys, leaving the "Control" key non-functional. Two modifier keys (plus the Shift key) are indeed sufficient for LyX, but there are situations when it becomes desirable to break out of this default choice.

This is true especially for users who are accustomed to Emacs, a popular all-purpose editor that has a long history on UNIX-like operating systems. Although LyX offers customized bind files which implement many Emacs key bindings, there is one crucial problem: wherever Emacs users expect to press the Control key, LyX requires them to press the Command key instead. This is extremely confusing for people who use both LyX and Emacs side by side. (The "Escape" key in LyX also functions differently from Emacs, because LyX only uses it as a "cancel" key.)

A Solution

On this page, we collect binaries that fix this problem by re-assigning the role of the modifier keys to make the Control key functional again. For versions up to 1.4.2, this was done by compiling the Qt libraries with a small patch. (Instructions for compiling the patched version can be found on the lyx-users mailing list.)

Here are links to binaries for LyX that contain the patch described above:

Most people who use a patched version of LyX also use an operating system-level keyboard mapper like uControl or fkeys to map the Caps Lock key to the Control modifier. The patched versions above do not do this mapping directly.

A Better (?) Solution

A major downside of the original solution is that a patched version of LyX needs to be compiled and distributed separately for every release. It would be much better if a single LyX distribution could be configured for either standard and "swapped" behavior.

An attempt at this is now available as a new patch for Qt 4.3.4, which has been used to create a patched version of LyX 1.5.4 compiled as a Universal binary.

You can install the patched version just like the official one. To swap the modifier keys, you will need to add a key called QtSwapModifiers to the .GlobalPreferences list in your home directory.

An easy way to do this is to type:

open ~/Library/Preferences/.GlobalPreferences.plist

in a Terminal window. Then, using the Property List Editor, select the Root node, click New Child to add a new key, and call the key QtSwapModifiers. Select the new key, then change its class to Boolean using the pop-up list. Its default value will be Yes. (If you want to turn off swapping, re-edit this file and change the value to No.) Changes will become effective the next time you start LyX.

This new solution has been tested on PPC and Intel Macs running Tiger and Leopard. If you find that it doesn't work as expected, feedback would be greatly appreciated.

There is some discussion of this issue on the lyx-devel mailing list.

Future Solutions

It would still be nice to avoid having to patch Qt at all.

Open questions include:

  • Would the Qt developers be willing to implement a more general modifier-swapping mechanism? We have logged this request with Trolltech as suggestion 205938. The private version of the task includes a description of the new patch and a link to this page.
  • Is there a clean way to provide a workaround by changing the LyX source code instead of Qt? This may be possible, but it's not clear that enough people are affected by this issue to make that worthwhile.
  • Can OS X itself, or one of the kernel extensions mentioned above, be used to solve the problem? The OS X System Preferences provide customizable modifier keys, even on a per-application basis. But (at least as of Tiger) it is not possible to switch the function of the Control and Command keys for all keyboard shortcuts in LyX. If anyone finds a solution for Leopard or beyond, please post it here.

Mac

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2008-04-05 04:57 CEST