在 Mac OS X 中将 Caps Lock 用作 Esc

发布于 2024-07-05 20:29:14 字数 66 浏览 5 评论 0原文

如何使 Caps Lock 在 Mac OS X 中像 Esc 一样工作?

How do I make Caps Lock work like Esc in Mac OS X?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

北座城市 2024-07-12 20:29:15

为了使用 PCKeyboardHack 和 KeyRemap4MacBook 实际交换转义键与大写锁定键(不仅仅是将一个键映射到另一个键),您必须按照 此线程,将大写锁定键映射到键盘未使用但由 KeyRemap4MacBook 占用的键码(例如 110)。 然后,在 PCKeyboardHack 中,选择将该键码映射到转义的适当选项(在 110 的情况下,它是“应用程序密钥转义”)。 您的 KeyRemap4MacBook 首选项应如下所示(前提是您已选中“仅显示已启用”复选框)。

在此处输入图像描述

我最初尝试发布此信息 作为对cwd的出色答案的编辑,但被拒绝了。 我鼓励任何想要走我描述的路线的人首先阅读他/她的回复。

In order to actually swap the escape key with the caps lock key (not just map one to the other) using both PCKeyboardHack and KeyRemap4MacBook, you have to follow the instructions in this thread, mapping the caps lock key to a keycode not used by the keyboard but accounted for by KeyRemap4MacBook (eg. 110). Then, in PCKeyboardHack, select the appropriate option that maps that keycode to escape (in the case of 110, it's "Application Key to Escape"). Here's what your KeyRemap4MacBook preferences should look like (provided you've selected the "show enabled only" checkbox).

enter image description here

I originally attempted to post this information as an edit to cwd's excellent answer, but it was rejected. I encourage anyone who wants to go the route that I describe to first read his/her response.

柠檬心 2024-07-12 20:29:15

打开键盘首选项并单击修饰键...您可以将大写锁定键更改为控制、选项、转义或命令。

在此处输入图像描述

Open up Keyboard preferences and click modifier keys... you can change the caps lock key to control, option, escape, or command.

enter image description here

遗失的美好 2024-07-12 20:29:15

Seil 尚无法在 macOS Sierra 上运行,因此我使用 Karabiner Elements,从 < a href="https://pqrs.org/latest/karabiner-elements-latest.dmg" rel="nofollow">https://pqrs.org/latest/karabiner-elements-latest.dmg。

使用 GUI 或将以下内容放入 ~/.karabiner.d/configuration/karabiner.json 中:

{
  "profiles" : [
    {
      "name" : "Default profile",
      "selected" : true,
      "simple_modifications" : {
        "caps_lock" : "escape"
      }
    }
  ]
}

Seil doesn't work on macOS Sierra yet, so I'm using Karabiner Elements, download from https://pqrs.org/latest/karabiner-elements-latest.dmg.

Either use the GUI or put the following into ~/.karabiner.d/configuration/karabiner.json:

{
  "profiles" : [
    {
      "name" : "Default profile",
      "selected" : true,
      "simple_modifications" : {
        "caps_lock" : "escape"
      }
    }
  ]
}
寒尘 2024-07-12 20:29:15

您还可以使用 DoubleCommand 重新映射此键和其他键。

IIRC,它将把 Caps Lock 映射到 Esc。

You can also use DoubleCommand to remap this, and other keys.

IIRC, it will map Caps Lock to Esc.

我只土不豪 2024-07-12 20:29:15

卡拉宾元件
适用于 macOS 的强大且稳定的键盘定制器。 (免费软件)

https://pqrs.org/osx/karabiner/index.html

为我在 Mojave 工作,将大写锁定更改为退格键

Karabiner-Elements
A powerful and stable keyboard customizer for macOS. (freeware)

https://pqrs.org/osx/karabiner/index.html

Worked for me for Mojave to change caps-lock to backspace

雨落星ぅ辰 2024-07-12 20:29:14

我唯一知道怎么做的就是将 Caps Lock 映射到 Control、Option 或 Command。 这可以通过键盘和键盘来完成。 系统偏好设置的鼠标窗格。 单击左下角的“修改键”,您将能够将 Caps Lock、Control、Option 和 Command 重新映射到其中任何一个。

@克雷格:
这表明 Caps Lock 可以用作普通(即非切换)键。 在我的 MacBook 上,由于我已将 Caps Lock 重新映射到 Control,因此 Caps Lock 指示灯永远不会亮起。 它的作用就像 Control 键。

在此处输入图像描述

The only thing I know how to do is to map Caps Lock to Control, or Option, or Command. This can be done via the Keyboard & Mouse pane of System Preferences. Click on "Modifier Keys" on the bottom left and you'll be able to remap Caps Lock, Control, Option, and Command, to any of those.

@Craig:
This suggests that Caps Lock can be used as a normal -- that is, non-toggle -- key. On my MacBook, since I have re-mapped Caps Lock to Control, the Caps Lock light never lights up. It simply acts like the Control key.

enter image description here

﹎☆浅夏丿初晴 2024-07-12 20:29:14

现在,使用 macOS Sierra 将 Caps Lock 键映射到 Esc 变得更加容易。

  1. 打开系统偏好设置→键盘。

  2. 单击右下角的“修改键”按钮。

  3. 单击您要重新映射的硬件键旁边的下拉框,然后选择“退出”。

    单击您要

  4. 单击“确定”并关闭“系统偏好设置”。

输入图像描述这里

https://9to5mac.com/2016/10/25/remap-escape-key-action-macbook-pro-macos-sierra-10-12-1-modifier-keys/< /a>

It is now much easier to map the Caps Lock key to Esc with macOS Sierra.

  1. Open System Preferences → Keyboard.

  2. Click the Modifier Keys button in the bottom right-hand corner.

  3. Click the drop down box next to the hardware key that you’d like to remap, and select Escape.

  4. Click OK and close System Preferences.

enter image description here

https://9to5mac.com/2016/10/25/remap-escape-key-action-macbook-pro-macos-sierra-10-12-1-modifier-keys/

没︽人懂的悲伤 2024-07-12 20:29:14

这是可能的。

解决方案 1

来自 TrueAffection.net 上的一篇文章

  • 下载 PCKeyboardHack 并安装。
  • 转至系统偏好设置中的 PCKeyboardHack。
  • 启用“更改大写锁定”并将键码设置为 53。

解决方案 2

此解决方案不涉及修补键盘驱动程序,但为您提供了 Vim 特定的解决方案。

OS X 支持将 Caps Lock 键映射到一大堆按键,但您必须“手动”完成此操作,编辑 .plist 文件。 本文中描述了该过程。 作为该提示的附录,我建议您首先在系统偏好设置中将 Caps-Lock 设置为 None,然后只需更改 .plist 文件中的一个值。 此外,您当然可以使用属性列表编辑器,而不是执行 XML 转换步骤。

诀窍是将 Caps Lock 键映射到帮助键(代码 6),大多数键盘上都没有该键。 但如果是,它将被视为插入键,您可能无论如何都不会使用它,因为您询问重新映射大写锁定以防止伸展您的手;)

然后您可以映射帮助和 插入 在 vi​​m 中按 Esc 键。

map  <Help> <Esc>
map! <Help> <Esc>
map  <Insert> <Esc>
map! <Insert> <Esc>

这适用于 gvim (Vim.app)。 我没有让它在终端中与 vim 一起工作,也没有在 MacVim 上测试它。

因此,这是一个相当复杂、不成熟的解决方案或安装第三方黑客技术。 你的选择;)

编辑:刚刚注意到解决方案 3,如果你使用 MacVim 你可以使用 CtrlOptionCommand 作为 Esc。 通过系统偏好设置,将 Caps Lock 映射到这些键之一非常简单。

It's possible.

Solution 1

From an arcticle on TrueAffection.net.

  • Download PCKeyboardHack and install it.
  • Go to PCKeyboardHack in System Preferences.
  • Enable ‘Change Caps Lock’ and set the keycode to 53.

Solution 2

This solution doesn't involve patching the keyboard driver, but gives you a Vim specific solution.

OS X supports mapping the Caps Lock key to a whole bunch of keys, but you have to do it 'by hand', editting .plist files. The process is described in this article. As addendum to that hint I suggest you first set Caps-Lock to None in the System Preferences, then you only need to change one value in the .plist file. Also, you can of course use the Property List Editor instead of going through the XML conversion steps.

The trick is to map the Caps Lock key to the Help key (code 6), which isn't on most keyboards. But if it is, it will be treated as the insert key, which you probably don't use anyway, since you ask about remapping your Caps Lock to prevent stretching your hands ;)

You can then map the Help and the Insert key to Esc in vim.

map  <Help> <Esc>
map! <Help> <Esc>
map  <Insert> <Esc>
map! <Insert> <Esc>

This will work for gvim (Vim.app). I didn't get it to work with vim in the Terminal and I haven't tested it with MacVim.

So, it's rather a complicated, half-baked solution or installing a third-party piece of hackery. Your pick ;)

Edit: Just noticed solution 3, if you're using MacVim you can use Ctrl, Option and Command as Esc. With the System Preferences it's trivial to map Caps Lock to one of those keys.

药祭#氼 2024-07-12 20:29:14

Seil 尚未在 macOS Sierra(10.12 beta)上使用。 因此,我一直在使用 Keyboard Maestro 并进行以下设置: 在此处输入图像描述

归功于此 github 评论:https://github.com/tekezo/Seil/issues/68#issuecomment-230131664

Seil isn't yet available on macOS Sierra (10.12 beta). As such, I've been using Keyboard Maestro with these settings: enter image description here

Credit to this github comment: https://github.com/tekezo/Seil/issues/68#issuecomment-230131664

煞人兵器 2024-07-12 20:29:14

尝试了其中几种解决方案后,我有一些注意事项:

DoubleCommand不允许你交换 esc 和 caps-lock 。

PCKeyboardHack允许您映射大写锁定转义,但没有能力将转义映射到大写锁定。 最新版本将允许您通过编辑两个密钥来执行完整的交换。

这可能足以满足您的需求,也可能不足以满足您的需求(我知道它适合我的需求)。

Having tried several of these solutions, I have some notes:

DoubleCommand will not allow you to swap esc and caps-lock.

PCKeyboardHack will allow you to map capslock to escape, but does not have the capability to map escape to capslock. Recent versions will allow you to perform a complete swap by editing both keys.

This may or may not be sufficient for your needs (I know it is for mine).

一抹微笑 2024-07-12 20:29:14

如果您不想安装第三方应用程序并且您实际上只关心 iTerm 中的 vim,则可以使用以下方法:

将 CapsLock 重新映射到帮助,如所述 此处

简短版本:使用 plutil 或类似工具编辑 ~/Library/Preferences/ByHost/.GlobalPreferences*.plist,它应该看起来类似于:

<key>HIDKeyboardModifierMappingDst</key>
<integer>6</integer>
<key>HIDKeyboardModifierMappingSrc</key>
<integer>0</integer>

重新启动! 简单的注销和登录对我来说不起作用。

在 iTerm 中,为帮助添加新的键映射:发送十六进制代码 0x1b,它对应于 Escape。

我知道这并不完全是所要求的,但我认为许多人寻找这样的解决方案的意图实际上是这种更专业的变体。

In case you don't want to install a third-party app and you really only care about vim inside iTerm, the following works:

Remap CapsLock to Help as described here.

Short version: use plutil or similar to edit ~/Library/Preferences/ByHost/.GlobalPreferences*.plist, it should look similar to this:

<key>HIDKeyboardModifierMappingDst</key>
<integer>6</integer>
<key>HIDKeyboardModifierMappingSrc</key>
<integer>0</integer>

Restart! A simple log-out and log-in did not work for me.

In iTerm, add a new key mapping for Help: send hex code 0x1b, which corresponds to Escape.

I know this is not exactly what was asked for, but I assume the intent of many people looking for a solution like this is actually this more specialized variant.

扎心 2024-07-12 20:29:14

在最新的 Ventura 更新中,系统设置发生了变化。

中找到它

您可以在系统设置> 。 键盘> 键盘快捷键> 修饰键

Mac OS Ventura 修改键菜单

With the latest Ventura update, System Settings changed.

You will find it on

System Settings > Keyboard > Keyboard Shortcuts > Modifier Keys

Mac OS Ventura Modifier Keys Menu

臻嫒无言 2024-07-12 20:29:14

编辑:此答案中所述,较新版本的 MacOS 现在原生支持重新绑定< kbd>Caps Lock 为 Escape。 因此不再需要安装第三方软件来实现这一点。


这是我尝试提供一个全面、直观的演练答案(带有链接),说明如何使用 Seil(以前称为 PCKeyboardHack)。

  1. 首先,进入系统偏好设置,选择键盘,然后选择键盘选项卡(第一个选项卡),然后单击修改键 strong>:

Step 1

在弹出对话框中将 Caps Lock Key 设置为 No Action:

选择不执行操作

2) 现在,点击此处下载 Seil 并安装:

3) 安装后,您将安装一个新的应用程序(Mountain Lion 及更新版本),如果您使用的是较旧的操作系统,您可能需要检查新的系统偏好设置窗格:

打开 seil 或首选项窗格

4) 选中“更改大写锁定”框,然后输入“53”作为转义键的代码:

设置键盘代码

大功告成! 如果它不能立即工作,您可能需要重新启动您的机器。

印象深刻吗? 想要更多控制吗?

您可能还想查看 KeyRemap4MacBook,它实际上是 pqrs 的旗舰键盘重新映射工具。 org - 它也是免费的。

如果您喜欢这些工具,您可以捐款。 我与他们没有任何关系,但我已经使用这些工具很长时间了,不得不说那里的人在维护这些工具、添加功能和修复错误方面做得非常出色。

下面的屏幕截图显示了一些(数百个)预选选项:

图片 1.png

PQRS 还有一个名为 NoEjectDelay 的实用程序,您可以使用它与 KeyRemap4MacBook 结合使用,对弹出键进行重新编程。 经过一些调整后,我设置了切换 AirPort Wifi。

这些实用程序在重新映射 Mac 键盘时提供无限的灵活性。 玩得开心!

Edit: As described in this answer, newer versions of MacOS now have native support for rebinding Caps Lock to Escape. Thus it is no longer necessary to install third-party software to achieve this.


Here's my attempt at a comprehensive, visual walk-through answer (with links) of how to achieve this using Seil (formerly known as PCKeyboardHack).

  1. First, go into the System Preferences, choose Keyboard, then the Keyboard Tab (first tab), and click Modifier Keys:

Step 1

In the popup dialog set Caps Lock Key to No Action:

choose no action

2) Now, click here to download Seil and install it:

3) After the installation you will have a new Application installed ( Mountain Lion and newer ) and if you are on an older OS you may have to check for a new System Preferences pane:

open seil or the preference pane

4) Check the box that says "Change Caps Lock" and enter "53" as the code for the escape key:

set the keyboard code

And you're done! If it doesn't work immediately, you may need to restart your machine.

Impressed? Want More Control?

You may also want to check out KeyRemap4MacBook which is actually the flagship keyboard remapping tool from pqrs.org - it's also free.

If you like these tools you can make a donation. I have no affiliation with them but I've been using these tools for a long time and have to say the guys over there have been doing an excellent job maintaining these, adding features and fixing bugs.

Here's a screenshot to show a few of the (hundreds of) pre-selectable options:

Picture 1.png

PQRS also has a great utility called NoEjectDelay that you can use in combination with KeyRemap4MacBook for reprogramming the Eject key. After a little tweaking I have mine set to toggle the AirPort Wifi.

These utilities offer unlimited flexibility when remapping the Mac keyboard. Have fun!

苄①跕圉湢 2024-07-12 20:29:14

从 macOS 10.12.1 开始,可以将 Caps Lock 重新映射到 Esc (Apple > 系统设置... > 键盘 > 键盘快捷键 > macOS 13 中的修改键) ,或者之前的系统偏好设置 -> 键盘 -> 修饰键)。

输入图像描述这里

Since macOS 10.12.1 it is possible to remap Caps Lock to Esc natively (Apple > System Settings… > Keyboard > Keyboard Shortcuts > Modifier Keys in macOS 13, or, before, System Preferences -> Keyboard -> Modifier Keys).

enter image description here

放赐 2024-07-12 20:29:14

我对这里的任何答案都不满意,并开始寻找命令行解决方案

在 macOS Sierra 10.12 中,Apple 为用户引入了一种重新映射按键的新方法。

  • 无需摆弄系统 GUI
  • 无需特殊权限
  • 完全可定制
  • 无需安装任何 3rd 方垃圾,如 PCKeyboardHack / Seil / Karabiner / KeyRemap4MacBook / DoubleCommand / NoEjectDelay

如果这听起来不错,请看一下 hidutil

例如,要将大写锁定重新映射为转义,请参阅 密钥表 并发现 caps-lock 的使用代码为 0x39,escape 的使用代码为 0x29。 将这些代码与十六进制值 0x700000000 放在源和目标中,如下所示:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}'

您可以在同一命令中添加其他映射。 就我个人而言,我喜欢将大写锁定重新映射为退格键,并将退格键重新映射为删除:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000002A}, {"HIDKeyboardModifierMappingSrc":0x70000002A,"HIDKeyboardModifierMappingDst":0x70000004C}]}'

要查看当前映射:

hidutil property --get "UserKeyMapping"

您的更改将在系统重新启动时丢失。 如果您希望它们持续存在,请在启动代理中配置它们。 这是我的:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Place in ~/Library/LaunchAgents/ -->
<!-- launchctl load com.ldaws.CapslockBackspace.plist -->
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.ldaws.CapslockEsc</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/hidutil</string>
      <string>property</string>
      <string>--set</string>
      <string>{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000002A},{"HIDKeyboardModifierMappingSrc":0x70000002A,"HIDKeyboardModifierMappingDst":0x70000004C}]}</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

我已将此内容放入位于 ~/Library/LaunchAgents/com.ldaws.CapslockBackspace.plist 的文件中,然后执行:

launchctl load com.ldaws.CapslockBackspace.plist

I wasn't happy with any of the answers here, and went looking for a command-line solution.

In macOS Sierra 10.12, Apple introduced a new way for users to remap keys.

  • No need to fiddle around with system GUIs
  • No special privileges are required
  • Completely customisable
  • No need to install any 3rd-party crap like PCKeyboardHack / Seil / Karabiner / KeyRemap4MacBook / DoubleCommand / NoEjectDelay

If that sounds good to you, take a look at hidutil.

For example, to remap caps-lock to escape, refer to the key table and find that caps-lock has usage code 0x39 and escape has usage code 0x29. Put these codes or'd with the hex value 0x700000000 in the source and dest like this:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}'

You may add other mappings in the same command. Personally, I like to remap caps-lock to backspace, and remap backspace to delete:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000002A}, {"HIDKeyboardModifierMappingSrc":0x70000002A,"HIDKeyboardModifierMappingDst":0x70000004C}]}'

To see the current mapping:

hidutil property --get "UserKeyMapping"

Your changes will be lost at system reboot. If you want them to persist, configure them in a launch agent. Here's mine:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Place in ~/Library/LaunchAgents/ -->
<!-- launchctl load com.ldaws.CapslockBackspace.plist -->
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.ldaws.CapslockEsc</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/hidutil</string>
      <string>property</string>
      <string>--set</string>
      <string>{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000002A},{"HIDKeyboardModifierMappingSrc":0x70000002A,"HIDKeyboardModifierMappingDst":0x70000004C}]}</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

I've placed this content into a file located at ~/Library/LaunchAgents/com.ldaws.CapslockBackspace.plist and then executed:

launchctl load com.ldaws.CapslockBackspace.plist
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文