Problem with AltGR on International Keyboards on MS Windows

Emacs keys may seem to be “hidden” (perhaps only) on MS Windows because AltGr + LeftControl + key is just AltGr + key. For example on a Swedish keyboard @ and \ are typed using AltGr. This means that all things bound to C-@ anywhere in a keymap (at any depth) are at least a bit difficult to type.

Note: I think the whole problem only exists under MS Windows because it implements AltGr as Alt + Left Control. For the X Window System e.g. Mode_switch, which is usually mapped to AltGr, is a different modifier, completely unrelated to Alt or Control.

Solution 1: Using the Right Control

But you can type those keys even on MS Windows! The trick is that you must type AltGr as the first key, and Ctrl must be the right control key, not the left one.

So, on my Spanish keyboard, I can do:

   C-M-@ => AltGr RCtrl Alt 2
   C-@   => AltGr RCtrl 2
   C-M-\ => AltGr RCtrl Alt º
   C-\   => AltGr RCtrl º
   C-]   => AltGr RCtrl +

just fine.

Solution 2: Using Alternate Key Bindings

It turns out that instead of C-@ you can always type C-SPACE. (Don’t ask me why, I have forgotten. Anyone remembers?)

So this makes it a lot easier to type these commands:

   C-M-@        mark-sexp          => C-M-SPACE
   C-@          set-mark-command   => C-SPACE
   C-x C-@      pop-global-mark    => C-x C-SPACE
   C-x r C-@    point-to-register  => C-x r C-SPACE

And indentation is so common so it has a very convenient binding:

   C-M-\        indent-region      => TAB

AltGr key combos without alternatives

The keys below are still troublesome. (Maybe there are more?) You need solution 1 here:

   M-{		backward-paragraph
   M-}		forward-paragraph
   M-$		ispell-word
   M-@		mark-word
   M-\		delete-horizontal-space
   M-|		shell-command-on-region
   C-]          abort-recursive-edit
   M-~		not-modified
   C-x RET C-\  set-input-method
   C-\		toggle-input-method
   C-h C-\	describe-input-method

Making it possible to actually type this: Sticky Modifiers

If actually type these difficult with AltGr combinations you are either probably a first class guitarist or a normal human using StickyModifiers. This is an OS feature. With those on you can type the keys one by one.

The order of things

Unfortunately using StickyModifiers is not enough. In the case with Alt Gr you also have to type the keys in a certain order.

Today (2006-12-17) I saw on Emacs developers list that RCtrl must be typed before AltGr. Seems like something has changed. Anyone else that have seen this?

Yes! It works very nice, thanks for the hint! Still, those shortcuts are real finger twisters, but now at least I can type them. Again, thanks! – MaDa, using a Swedish keyboard

Today (2007-02-20) I have to type AltGr before RCtrl again. Even if I use an old CVS Emacs from the date above. Anyone who understands this?

Problem with foot pedal which memorized Control_L+Mode_switch instead of AltGr

I use a Kinesis device with 2 programmable pedals, and I want AltGr for one of them. Since they don’t support GNU, I had to use a Windows computer to record the key (it’s just pressing AltGr after turning a switch below the device). The problem is, after that the pedal sends Ctrl+Alt instead of AltGr. With xev I detect Control_L and then Mode_switch (two key presses) when I press the pedal one time. Do you know how can I teach X to see this as one key?, or how can I help the Windows driver (X-keys) to store AltGr really as AltGr? – 4.m7.2010 DanielClemente

Questions and suggestions

Esc-Ctrl-@, for example, will work for this on every platform. (Aidan Kehoe, Mon Nov 30 16:20:24 GMT 2009)

Unfortunately it will not work at all if you are using Viper. And you have the same problem with Alt Gr here.

On Linux, if you don’t need AltGr, you can remap it to Alt for use in text-mode Emacs by using the loadkeys command. For Example:

    # loadkeys /usr/share/kbd/keymaps/i386/qwerty/ /usr/share/kbd/keymaps/i386/include/

This sets the keymap to UK, including a file mapping AltGr to Alt. Alternatively, for a more permanent change, edit your existing keymap file and add:

    keycode 100 = Alt