pqrs-org / Karabiner-archived

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.
https://pqrs.org/osx/karabiner/
The Unlicense
3.82k stars 311 forks source link

Using private.xml #605

Closed eltang closed 8 years ago

eltang commented 8 years ago
<?xml version="1.0"?>
<root>
  <devicevendordef>
    <vendorname>APPLE_INC</vendorname>
    <vendorid>0x05ac</vendorid>
  </devicevendordef>
  <deviceproductdef>
    <productname>APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0259</productname>
    <productid>0x0259</productid>
  </deviceproductdef>
  <devicevendordef>
    <vendorname>ORTHOLINEAR_KEYBOARDS</vendorname>
    <vendorid>0xFEED</vendorid>
  </devicevendordef>
  <deviceproductdef>
    <productname>THE_PLANCK_KEYBOARD</productname>
    <productid>0x6060</productid>
  </deviceproductdef>
  <item>
    <name>Menu to Caps in THE_PLANCK_KEYBOARD</name>
    <identifier>private.menu_to_caps</identifier>
    <device_only>DeviceVendor::ORTHOLINEAR_KEYBOARDS, DeviceProduct::THE_PLANCK_KEYBOARD</device_only>
    <autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::CAPSLOCK</autogen>
  </item>
  <item>
    <name>Delete to Caps in APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0259</name>
    <identifier>private.delete_to_caps</identifier>
    <device_only>DeviceVendor::APPLE_INC, DeviceProduct::APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0259</device_only>
    <autogen>__KeyToKey__ KeyCode::DELETE, KeyCode::CAPSLOCK</autogen>
  </item>
  <item>
    <name>Menu to Delete in APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0259</name>
    <identifier>private.menu_to_delete</identifier>
    <device_only>DeviceVendor::APPLE_INC, DeviceProduct::APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0259</device_only>
    <autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::DELETE</autogen>
  </item>
</root>

My goal is to swap Caps Lock and Backspace on my internal keyboard but not on my external keyboard. This private.xml file I made does not work as intended. I used Seil to remap the Caps Lock keys on both my internal and external keyboards to Menu keys so that they can be more easily handled by Karabiner. Then, I made this file to try to complete the swap, but the Delete key on my external keyboard is still getting remapped to Caps Lock.

tekezo commented 8 years ago

Your private.xml should work. Did you change the delete key in other prepared settings?

eltang commented 8 years ago

No, the three settings here are the only ones I have enabled. That was the problem! Everything works now. Thanks!

eltang commented 8 years ago

By the way, is there a way that I can make the latter two settings apply to all external keyboards other than my Planck? I don't want to keep adding stuff to this file every time I use a new type of keyboard with my computer.

tekezo commented 8 years ago

You can use <device_not> filter.

eltang commented 8 years ago
<?xml version="1.0"?>
<root>
  <devicevendordef>
    <vendorname>ORTHOLINEAR_KEYBOARDS</vendorname>
    <vendorid>0xFEED</vendorid>
  </devicevendordef>
  <deviceproductdef>
    <productname>THE_PLANCK_KEYBOARD</productname>
    <productid>0x6060</productid>
  </deviceproductdef>
  <item>
    <name>Menu to Caps in THE_PLANCK_KEYBOARD</name>
    <identifier>private.menu_to_caps</identifier>
    <device_only>DeviceVendor::ORTHOLINEAR_KEYBOARDS, DeviceProduct::THE_PLANCK_KEYBOARD</device_only>
    <autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::CAPSLOCK</autogen>
  </item>
  <item>
    <name>Delete to Caps in ANY</name>
    <identifier>private.delete_to_caps</identifier>
    <device_not>DeviceVendor::ORTHOLINEAR_KEYBOARDS, DeviceProduct::THE_PLANCK_KEYBOARD</device_not>
    <autogen>__KeyToKey__ KeyCode::DELETE, KeyCode::CAPSLOCK</autogen>
  </item>
  <item>
    <name>Menu to Delete in ANY</name>
    <identifier>private.menu_to_delete</identifier>
    <device_not>DeviceVendor::ORTHOLINEAR_KEYBOARDS, DeviceProduct::THE_PLANCK_KEYBOARD</device_not>
    <autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::DELETE</autogen>
  </item>
  <item>
    <name>Swap Tab and Enter in ANY</name>
    <identifier>private.swap_tab_and_enter</identifier>
    <device_not>DeviceVendor::ORTHOLINEAR_KEYBOARDS, DeviceProduct::THE_PLANCK_KEYBOARD</device_not>
    <autogen>__KeyToKey__ KeyCode::TAB, KeyCode::ENTER</autogen>
    <autogen>__KeyToKey__ KeyCode::ENTER, KeyCode::TAB</autogen>
  </item>
</root>

Okay, so that filter seems to work, but I was unable to successfully add another option (the last one). I tried to swap Tab and Enter, but the latter key has not changed. This time I am sure that no conflicting settings are enabled.

eltang commented 8 years ago

Apparently my keyboard was outputting RETURN rather than ENTER as I thought.

tekezo commented 8 years ago

EventViewer is useful to investigate the KeyCode. https://pqrs.org/osx/karabiner/document.html.en#eventviewer

eltang commented 8 years ago

That's indeed what tipped me off.