在 Windows 上的 Emacs 中将 Caps Lock 映射到控件 [英] Mapping Caps Lock to Control from within Emacs on Windows

查看:23
本文介绍了在 Windows 上的 Emacs 中将 Caps Lock 映射到控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读 这些 问题或<一个 href="http://www.emacswiki.org/emacs/MovingTheCtrlKey#toc​​12" rel="nofollow noreferrer">EmacsWiki 文章关于在 Windows 中的 emacs 中映射 Caps Lock 到 Control,最好的答案似乎涉及注册表.我的问题是当用户因为没有管理员权限而无法修改机器的注册表时,他们可以做什么.有没有办法从 emacs 中进行映射?这篇文章非常接近,甚至说,正如人们所提到的,您当然可以将 Caps-Lock 映射到其他键,例如 Control 键."但我不知道如何表示控制键(使用 各种参考,看起来很全面,但可能不是以 Windows 为中心的),尝试诸如

When reading either of these questions or the EmacsWiki article about mapping Caps Lock to Control in emacs in Windows, the best answers seem to involve the registry. My question is what a user can do when they can't modify the registry of the machine because they don't have admin rights. Is there a way to do the mapping from within emacs? This article comes oh-so-close, even saying, "As people have mentioned, you can of course map Caps-Lock to other keys instead, for example the Control key." But I can't figure out how to represent the control key (using various references that look pretty comprehensive but might not be Windows-centric), trying things like

(setq w32-enable-caps-lock nil)
(global-set-key [capslock] '[control])

(setq w32-enable-caps-lock nil)
(global-set-key [capslock] 'ctl-x-map)

这似乎不起作用.

推荐答案

我知道这并不能真正回答您的问题,但 Trey Jackson 基本上解释了问题.单独检测控制键需要 Windows 上的低级键盘钩子,我认为 Emacs 没有实现.

I know this does not really answer your question, but Trey Jackson basically explained the problem. To detect control key alone requires low-level keyboard hook on Windows, which I don't think Emacs implements.

一种方法(涉及外部程序,但不需要管理员权限)是使用 AutoHotkey.您只需要以下两行脚本:

One way (involving external program, but does not require admin right) is to use AutoHotkey. All you need is the following 2 line script:

CapsLock::Ctrl
LCtrl::Capslock

每当 emacs 打开时,您都需要运行此脚本,但幸运的是 Autohotkey 是非常低调的应用程序(通常仅占用大约数百 Kb 的内存).例如,您可以在 .emacs 中执行此脚本,以便在打开 emacs 时交换控制键和大写锁定键.

You will need to run this script whenever emacs is open, but thankfully Autohotkey is pretty low profile application (usually takes about a few hundreds Kb in memory only). You can for example execute this script in your .emacs so that your control key and capslock key are swapped whenever emacs is opened.

这篇关于在 Windows 上的 Emacs 中将 Caps Lock 映射到控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆