您可以使用PCKeyboardHack将大写锁定更改为 F19。然后将其保存为private.xml:
<?xml version="1.0"?>
<root>
<item>
<name>caps1</name>
<identifier>caps1</identifier>
<autogen>__KeyToKey__ KeyCode::F19, KeyCode::CAPSLOCK</autogen>
</item>
<item>
<name>caps2</name>
<identifier>caps2</identifier>
<autogen>__KeyToKey__ KeyCode::F19, KeyCode::CONTROL_L</autogen>
</item>
</root>
并使用此脚本来切换设置:
k=/Applications/KeyRemap4MacBook.app/Contents/Applications/KeyRemap4MacBook_cli.app/Contents/MacOS/KeyRemap4MacBook_cli
if $k changed | grep -q ^caps1=; then
$k disable caps1
$k enable caps2
else
$k enable caps1
$k disable caps2
fi
不过,将另一个组合键分配给 caps lock 会更容易:
<autogen>__KeyOverlaidModifier__ KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CAPSLOCK</autogen>
这将在按键按下时触发,因此您必须在 fn 之前按下 control 以获取诸如 fn+control+down 之类的组合键:
<autogen>__KeyToKey__ KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CAPSLOCK</autogen>