How to remap keys when in Emacs?

99封情书 提交于 2019-12-10 12:56:21

问题


I am looking for a way to have my control key and caps-lock key switched when I am in the emacs window, but when I go to any other program such as Firefox I want to be able to use the normal control button for new windows, tabs and such.

Additional Information: I am using Ubuntu, but answers for all systems are good since someone else may want to know how to do it on their system.


回答1:


Emacs never actually sees the CapsLock keycode (under X anyway), so you can't remap the key in Lisp. Take a look at this page for details:

http://www.emacswiki.org/emacs/MovingTheCtrlKey




回答2:


On windows using Auto Hot Key you can achieve this with this piece of code put in default script:

#IfWinActive, emacs@      
    CapsLock::Control
#IfWinActive

Auto Hot Key is a very handy utility and it is also free software like in GPL.




回答3:


For globally remapping keys there is xmodmap. xkeycaps is an interactive tool. You can put control on both keys.

Since you want to remap the keys only for Emacs (which I find somewhat ill-advised) you need to look inside Emacs for a solution. It should be possible, because you can rebind all keys, but it may be too tedious to swap all keys around if the modifiers cannot be swapped.

Personally I map CapsLock to Compose, to type all kinds of funny characters like ä, ß, å, þ, «, —, ...



来源:https://stackoverflow.com/questions/508874/how-to-remap-keys-when-in-emacs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!