Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefining keys in Emacs on Windows

I use my command keys as extra control keys on Mac OS X (and I believe the space cadet keyboards had this configuration). I want to emulate this on my Windows machines by switching Alt to Ctrl and the Windows key to Alt within Emacs. Is this possible? I found this post which suggests something like

(setq w32-pass-lwindow-to-system nil 
      w32-pass-rwindow-to-system nil 
      w32-pass-apps-to-system nil 
      w32-lwindow-modifier 'super ;; Left Windows key 
      w32-rwindow-modifier 'super ;; Right Windows key 
      w32-apps-modifier 'hyper) ;; Menu key

to get super and hyper keys upon pressing the windows key. When I try to remap this to 'control to test it out (but eventually I want it to be meta and Alt as Ctrl, as mentioned), windows-e still gets intercepted by Windows (XP) and opens Explorer, but seems like a good place to start? I would appreciate any suggestions.

like image 749
hatmatrix Avatar asked Sep 14 '10 12:09

hatmatrix


1 Answers

From the documentation for w32-pass-lwindow-to-system:

Note that some combinations of the left "Windows" key with other keys are caught by Windows at low level, and so binding them in Emacs will have no effect. For example, <lwindow>-r always pops up the Windows Run dialog, <lwindow>-<Pause> pops up the "System Properties" dialog, etc. However, see the doc string of `w32-phantom-key-code'.

From the documentation for w32-phantom-key-code:

Virtual key code used to generate "phantom" key presses. Value is a number between 0 and 255. Phantom key presses are generated in order to stop the system from acting on "Windows" key events when `w32-pass-lwindow-to-system' or `w32-pass-rwindow-to-system' is nil.

And as it also says on Xah's website:

There's no way around that unless you use other tools such as AutoHotkey. Even so, it may not be possible to disable 【Win+l】 (lock window) and 【Win+u】 (easy access).

So it seems that if it doesn't work with the method he describes (which seems right), you should look into AutoHotKey.

like image 120
Deniz Dogan Avatar answered Oct 11 '22 08:10

Deniz Dogan