HOW-TO: Get the ALT key to function properly under Mac OS X
HOW-TO: Get the ALT key to function properly under Mac OS X
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!
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!
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Hi - I just tested your gorgeous tip on Leopard with Inkscape 0.46.1 and it works perfect. In my X11 the item "Use teh system keyboard layout" is called "Follow system keyboard input", and at the end the steps I had to restart X11.
Thanks for that tip!
Thanks for that tip!
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thanks for testing that KurTell. I'm glad that more-or-less it's the same solution under Leopard as it is for Tiger.
By the way, since the solution was really an adjustment for X11 (rather than an Inkscape fix, per se) I'm sure that this might also be useful for other X11 applications like OpenOffice, GIMP, GIMPShop, etc.
By the way, since the solution was really an adjustment for X11 (rather than an Inkscape fix, per se) I'm sure that this might also be useful for other X11 applications like OpenOffice, GIMP, GIMPShop, etc.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thanks for the great tip. It works fine, except that I had to type commands in a Terminal window (in my xterm commands xmodmap or xev were not working). After a short try, I adjusted your modification of the .Xmodmap file by letting the Keycode 69 unchanged, this way I have access to the 2 behavior of alt key : left one for inkscape commands, right one for text purposes (for instance for characters "}" or "]" which I get with alt + ) and shift + alt + ) on my french keyboard).
I still have a problem with text kerning though: I can translate characters with alt + arrows, but to rotate them I'm suppose to use alt + ]. There is no such key as ] on my french keyboard, and if I try a 4 key combination like alt (left) + alt (right) + shift + ) it doesn't work. The 2 keys right to the P of the keyboard, which I believe to be [ and ] on US keyboard, don't do the job either. Any idea on how to deal with this ?
Thanks,
Ludovic.
I still have a problem with text kerning though: I can translate characters with alt + arrows, but to rotate them I'm suppose to use alt + ]. There is no such key as ] on my french keyboard, and if I try a 4 key combination like alt (left) + alt (right) + shift + ) it doesn't work. The 2 keys right to the P of the keyboard, which I believe to be [ and ] on US keyboard, don't do the job either. Any idea on how to deal with this ?
Thanks,
Ludovic.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Ludovic B.,
Well, I think I've found a solution but it's not the prettiest.
First, some details:
- you may have noticed that X11 doesn't seem to be able to tell the difference between the two ALT keys (at least this is true on my newish external aluminum keyboard (and I confirmed the same on one of the older thicker external keyboards). This can be confirmed by running "xev" and noting that either ALT key gives you the "Meta_L" (assuming this HOW-TO has been followed and your .Xmodmap file adjusted).
- thus, even if you've left the Keycode 69 unchanged (i.e. still Mode_switch) I don't think X11 will be able to interpret it correctly. This was confirmed by my testing where I changed the Keycode 66 to "Meta_L", left 69 unchanged, and switched my keyboard type in "System Preferences > International > Input Menu" to Canadian French - in Inkscape pressing both ALT keys plus "9" or "0" gave me "Inset path" and "Outset path" respectively, not the intended rotation you're after
So, what I did instead was change the Keycodes 91 and 92 in my .Xmodmap file to the following:
keycode 91 = bracketleft
keycode 92 = bracketright
These keys correspond to the numbers 1 and 2 on the numeric keypad. This of course assumes that you have a numeric keypad and that you're fine with entering any 1's and 2's via the normal method.
My thought process was "okay, let's just find two unnecessary keys that I can force to explicitly be the "bracketleft" and "bracketright" codes. In reviewing the French keyboard layout (or the English for that matter) there's just so few choices for better candidates than the numeric keypad.
Maybe somebody out there with deeper X11/xmodmap kung fu can further this solution or provide a less-obtrusive one...
F.North
Well, I think I've found a solution but it's not the prettiest.
First, some details:
- you may have noticed that X11 doesn't seem to be able to tell the difference between the two ALT keys (at least this is true on my newish external aluminum keyboard (and I confirmed the same on one of the older thicker external keyboards). This can be confirmed by running "xev" and noting that either ALT key gives you the "Meta_L" (assuming this HOW-TO has been followed and your .Xmodmap file adjusted).
- thus, even if you've left the Keycode 69 unchanged (i.e. still Mode_switch) I don't think X11 will be able to interpret it correctly. This was confirmed by my testing where I changed the Keycode 66 to "Meta_L", left 69 unchanged, and switched my keyboard type in "System Preferences > International > Input Menu" to Canadian French - in Inkscape pressing both ALT keys plus "9" or "0" gave me "Inset path" and "Outset path" respectively, not the intended rotation you're after
So, what I did instead was change the Keycodes 91 and 92 in my .Xmodmap file to the following:
keycode 91 = bracketleft
keycode 92 = bracketright
These keys correspond to the numbers 1 and 2 on the numeric keypad. This of course assumes that you have a numeric keypad and that you're fine with entering any 1's and 2's via the normal method.
My thought process was "okay, let's just find two unnecessary keys that I can force to explicitly be the "bracketleft" and "bracketright" codes. In reviewing the French keyboard layout (or the English for that matter) there's just so few choices for better candidates than the numeric keypad.
Maybe somebody out there with deeper X11/xmodmap kung fu can further this solution or provide a less-obtrusive one...
F.North
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
This worked. Thanks. Now to kern.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Worked perfectly for me on 10.5.2, and was done in 2 min. Thanks a lot! Post to Inkscape wiki?
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Hi there,
I followed the instructions carefully, twice, and still can't change the baseline with Alt+up or Alt+down. I'm using a Macbook Pro with a Spanish keyboard, maybe I am not hitting the right key or key combo? But I have tried a lot of other combinations, like cmd-alt, ctrl-alt, etc. Help please!
CHFels
I followed the instructions carefully, twice, and still can't change the baseline with Alt+up or Alt+down. I'm using a Macbook Pro with a Spanish keyboard, maybe I am not hitting the right key or key combo? But I have tried a lot of other combinations, like cmd-alt, ctrl-alt, etc. Help please!
CHFels
works for GIMP 2.4.6 on Mac osx 10.5 Leopard
mapping the alt keys to Meta_L lets you access menu commands via the keyboard (alt + underlined letter) once again.
Works for GIMP 2.4.6 on Mac OSX 10.5 Leopard.
Thanks a lot!
Thomas
Works for GIMP 2.4.6 on Mac OSX 10.5 Leopard.
Thanks a lot!
Thomas
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thanks so much for this tip! I had to add /usr/X11R6/bin to my path variable in my bash profile and for some odd reason
I was seeing Alt_L and Alt_R instead of Meta_L and Meta_R on my network, so that's what I used and it worked nicely.
For the person who had trouble running X apps from his terminal windows, you probably need to set your DISPLAY environment var.
In bash:
export DISPLAY=:0.0
worked for me.
I was seeing Alt_L and Alt_R instead of Meta_L and Meta_R on my network, so that's what I used and it worked nicely.
For the person who had trouble running X apps from his terminal windows, you probably need to set your DISPLAY environment var.
In bash:
export DISPLAY=:0.0
worked for me.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
For anyone who is not running the default X11 server, I have another requirement. (For example, this applies to anyone running KDE instead of Apple's X11; this is useful, for example, if you use a lot of X11 programs and don't like how the Apple X11 works.)
In this case, the ~/.Xmodmap file may not be loaded automatically. In such a case, you could type into a terminal, after the X11 server is running $ xmodmap ~/.Xmodmap
Alternatively, edit the file ~/.xinitrc and add the line xmodmap ~/.Xmodmap
In principle, this should already be done, but for my case, the Xmodmap in my home directory was not being loaded.
In generally, I would say this write-up is too elaborate. All you need to do is just make an .xmodmap file in your home directory with the correct keycodes. As another reader has pointed out, you can get a keycode using xev, and then if you can remap any key you want by looking up the name for keys. I'd agree that xmodmapping is not for the faith of heart, but if you want to remap keys in X11, well, that's what you use!
In this case, the ~/.Xmodmap file may not be loaded automatically. In such a case, you could type into a terminal, after the X11 server is running $ xmodmap ~/.Xmodmap
Alternatively, edit the file ~/.xinitrc and add the line xmodmap ~/.Xmodmap
In principle, this should already be done, but for my case, the Xmodmap in my home directory was not being loaded.
In generally, I would say this write-up is too elaborate. All you need to do is just make an .xmodmap file in your home directory with the correct keycodes. As another reader has pointed out, you can get a keycode using xev, and then if you can remap any key you want by looking up the name for keys. I'd agree that xmodmapping is not for the faith of heart, but if you want to remap keys in X11, well, that's what you use!
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thanks for posting.
My primary use of the alt key is to use within the text editor called nedit. I also want to be have access to the three button mouse - in particular, I often wish to be able to paste highlighted text in one xterm window into another window. I have an Apple Might Mouse (came with the iMac) but the multiple buttons thereon do not seem to map to the center and right buttons of a standard unix mouse. Can that be altered? In the meantime, I find that if I check the "Emulate three button mouse" preference, the alt key still seems to work as desired - so at present, I have a work around.
My question is - am I just getting lucky because of the way in which nedit is using the alt key and, unbeknownst to me, I am possibly heading for trouble later because confusion will arise between the alt key mapping and three button emulation that you recommend be switched off?
StephenB
My primary use of the alt key is to use within the text editor called nedit. I also want to be have access to the three button mouse - in particular, I often wish to be able to paste highlighted text in one xterm window into another window. I have an Apple Might Mouse (came with the iMac) but the multiple buttons thereon do not seem to map to the center and right buttons of a standard unix mouse. Can that be altered? In the meantime, I find that if I check the "Emulate three button mouse" preference, the alt key still seems to work as desired - so at present, I have a work around.
My question is - am I just getting lucky because of the way in which nedit is using the alt key and, unbeknownst to me, I am possibly heading for trouble later because confusion will arise between the alt key mapping and three button emulation that you recommend be switched off?
StephenB
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thanks for these instructions - it was exactly what I needed. I was wondering why ALT+> wasn't increasing the character spacing before! I'm using 10.5.5 and Xquartz 2.1.5. As with a previous poster, my X11 Preference setting was "Follow system keyboard layout".
I'm a novice terminal user - and for some reason, the xmodmap -pke > ~/.Xmodmap wasn't creating the file in my Home directory. I ended up having to copy the key mappings out from the terminal window and manually create the file using TextEdit. In any case, I can now adjust character spacing! Thanks for the help.
I'm a novice terminal user - and for some reason, the xmodmap -pke > ~/.Xmodmap wasn't creating the file in my Home directory. I ended up having to copy the key mappings out from the terminal window and manually create the file using TextEdit. In any case, I can now adjust character spacing! Thanks for the help.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thank you - worked perfectly 
OS X 10.5.6

OS X 10.5.6
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Thanks for the great tip; not being able to kern was starting to get really frustrating.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
I'm not able to get any of these tips to work on my iMac alu (and alu keyboard), danish keyboard, Mac OSX 10.5.6, Xquartz 2.1.5.
(getting the Alt+underlined letter IS working)
My big problem is that i can't kern my text within Inkscape. Followed every intruction, but still can't kern my text.
HELP.
I'm totally frustrated, tried for several days. TOTAL noob using Term and Xterm.
(getting the Alt+underlined letter IS working)
My big problem is that i can't kern my text within Inkscape. Followed every intruction, but still can't kern my text.
HELP.
I'm totally frustrated, tried for several days. TOTAL noob using Term and Xterm.
-
- Posts: 2
- Joined: Thu Apr 16, 2009 7:47 am
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
very useful information
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Great, worked for me! Thank you a lot!
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
...for someone on a Mac, running Leopard and X11 2.1.5 (although I am updating it) who is utterly ignorant of 'terminal' 'bash' etc etc, the instructions to activate manual kerning in Inkscape were a bit baffling. I managed to open the Terminal window, type in the first line given: xmodmap-pke>~/.Xmodmap; to which it replied 'file or directory unknown', so now I am stymied.
Is this seemingly quite advanced mucking around in the innards of the X11 coding really the only way to fix this?
Cheers.
Is this seemingly quite advanced mucking around in the innards of the X11 coding really the only way to fix this?
Cheers.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
I'm using a MacBookPro 4.1 (early 2008). I tried what Francis North recommended in the first post. The reason I did it was different -- I don't use inkscape. I was trying to get a WinXP SP3 virtual machine running in Virtual Box 2.1.4 to allow me to input Alt+[code] characters in Windows applications from my MacBook Pro keyboard. I'm new to Macs, so maybe I'm missing something. And, yes, I just realized that my MBP does NOT have the Num Lock capability! 

Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Guest (Eric) wrote:I'm using a MacBookPro 4.1 (early 2008). I tried what Francis North recommended in the first post. The reason I did it was different -- I don't use inkscape. I was trying to get a WinXP SP3 virtual machine running in Virtual Box 2.1.4 to allow me to input Alt+[code] characters in Windows applications from my MacBook Pro keyboard. I'm new to Macs, so maybe I'm missing something. And, yes, I just realized that my MBP does NOT have the Num Lock capability!
If anyone would like to see the discussion of this (so far no solution), you may go to the Virtual Box forum link: http://forums.virtualbox.org/viewtopic. ... 14&start=0.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
That's a great help! Thanks so much.. I'm new to Inkscape and thought it was me misunderstanding the Alt commands, seems not!
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
Works like a charm.
Thanks a bunch.
Thanks a bunch.
Re: HOW-TO: Get the ALT key to function properly under Mac OS X
thanks - works with 10.5.7 + XQuartz 2.3.3.2 + inkscape 0.46