Friday, July 24, 2009

HOW-TO: Get the ALT key to function properly under Mac OS X in Inkscape (and other X11 apps)




This is a repost of my April 5, 2008 posting on InkscapeForum.com.

---

I've spent the last day or so struggling to get the ALT key working properly, and would like to share my solution. While there are a few postings out there on this topic, I've yet to find one that addresses both the lack of ALT key functionality and the correct displaying of ALT-key related status bar text.

Before proceeding, please be aware that this approach will overwrite any existing ".Xmodmap" file in your home directory, should one be present (if this makes no sense to you then don't worry, you probably don't have one and are safe to proceed). Also, I've tested this with Tiger, and with a two-button mouse. I'm not sure how Leopard differs (perhaps someone can confirm this?) and am not sure how this will function with a one-button mouse since we're going to need to turn off the X11 setting that handles three-button emulation for the button-challenged users out there.

Step-by-step instructions

1
Launch X11 from Applications/Utilities

2
Open the preferences window and enable the "Use the system keyboard layout" preference. This will force X11 to use it's system default keyboard layout.

3
Open an xterm window (Command-N) and perform the following:

$ xmodmap -pke > ~/.Xmodmap

This captures the current xmodmap settings to a hidden file located in your home directory. It's this ~/.Xmodmap file that X11 will by default use to override any system mappings.

4
Edit your .Xmodmap file by typing the following in the same xterm window:

$ open -e ~/.Xmodmap

Change the line: "keycode 66 = Mode_switch" to "keycode 66 = Meta_L"
Change the line: "keycode 69 = Mode_switch" to "keycode 69 = Meta_R"

Save the file and exit TextEdit.

5
Disable the X11 preferences "Emulate three button mouse" and "Use the system keyboard layout", then close the preferences window.

These settings basically say "don't treat ALT as a special key, and don't override my .Xmodmaps file with system defaults".

6
Close the X11 preferences window, any opened xterm windows, and then the X11 application.

That's it. Now when you launch Inkscape, the ALT key should work as expected, and the status-bar will correctly display any ALT-key-specific help when that key is pressed (e.g. when using the Selection tool).

One final note: from an xterm window, you can debug your key mappings by typing "xev". This program will open an interactive test window that will echo information about current key/mouse presses, and is a handy utility for determining keycodes and what they're currently mapped to.

Feel free to provide any feedback and/or request for further clarification.

Happy ALT-keying!


5 comments:

  1. Thank you for publishing this, it hepled a lot!

    ReplyDelete
  2. My alt key now works in kerning text when I use the < and > keys to adjust the spacing between letters but it doesn't seem to work when I use the arrow and bracket keys to rotate the letters or adjust them up or down. Any suggestions would be appreciated, thanks!

    ReplyDelete
  3. Will this solution allow ribbon shortcut functionality to Microsoft Office 2011 for the Mac OS X? In MS Office 2007 and 2010 (PC versions), for example, when you press the alt key, alphanumeric characters appear on the ribbon. I was wondering if this solution you have described above will allow this functionality.

    Thanks for your help!

    ReplyDelete
  4. any way of making this a Script to Dl and it just work for us?

    ReplyDelete