Karabiner:Keyboard remapping in MacOSX

  本篇介绍MacOSX下键位映射软件Karabiner的配置和使用。

  目录:

  1.介绍

  2.下载

  3.软件配置

  4.参考资料

1.介绍

  Karabiner前身是KeyRemap4MacBook,是一款免费并且功能强大的键位映射工具软件。内置了很多按键映射,可以按照用户自己的想法定义按键效果,同时可以实现一键切换映射功能和针对特定场景的映射切换。

2.下载

  下载地址为:https://pqrs.org/osx/karabiner/

3.软件配置

  在Karabiner主界面,已经提供很多按键映射方案,可以灵活选择自己所需要的方案。如下:

 

  同时Karabiner还提供自定义按键映射。通过private.xml文件,用户可以方便的设计适合自己的按键方案。

  

    private.xml中几个重要的配置项:

  1.devicevendordef:键盘的生产厂商;vendorname:自定义名字(唯一);vendorid:厂商编号

  2.deviceproductdef:键盘的型号;productname:自定义名字(唯一);vendorid:型号编号

  以上两项可以在Karabiner->Launch EventViewer->Devices中查看(前提是键盘已经接入):

    

  3.item:为配置界面的配置项,如下:

   

  name:界面上显示的描述

  identifier:标识

  device_only:只有这里声明的设备才会应用我们的配置,如不填,则表示所有设备通用。

  auto_gen:按键映射

  参考private.xml如下:

<?xml version="1.0"?>
<root>
    <devicevendordef>
        <vendorname>Topre_Corporation</vendorname>
        <vendorid>0x0853</vendorid>
    </devicevendordef>
    <deviceproductdef>
        <productname>Realforce_87</productname>
        <productid>0x0111</productid>
    </deviceproductdef>
    
    <item>
        <name>change rf to mac layout</name>
        <identifier>rf_mac</identifier>
        <device_only>DeviceVendor::Topre_Corporation, DeviceProduct::Realforce_87</device_only>
        <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
        <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
        <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen>
        <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen>
        <autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::FN</autogen>
        <autogen>__KeyToKey__ KeyCode::FORWARD_DELETE, KeyCode::DELETE, ModifierFlag::COMMAND_R</autogen>
        <autogen>__KeyToKey__ KeyCode::F3, KeyCode::DASHBOARD</autogen>
        <autogen>__KeyToKey__ KeyCode::F4, KeyCode::LAUNCHPAD</autogen>
    </item>
</root>

  其他高级配置可以自行查看4中的提供的资料。

4.参考资料

  https://pqrs.org/osx/karabiner/xml.html.en

知识共享许可协议
本作品由江俊杰(Steven Jiang)创作,采用知识共享署名 4.0 国际许可协议进行许可。
原文地址:https://www.cnblogs.com/stevenjiang/p/4836558.html