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

question about my private.xml #758

Closed lanox closed 4 years ago

lanox commented 7 years ago

Hi I have leopold fc660C and I am trying to allocate keys for music. Here is my private.xml

<?xml version="1.0"?>
<root>
  <item>
    <name>Change Inser to FN</name>
    <item>
      <name>Help to FN</name>
      <identifier>private.help2fn</identifier>
      <autogen>__KeyToKey__ KeyCode::HELP, KeyCode::FN</autogen>
    </item>
  </item>
  <item>
    <name>Functional Keys F1...F12</name>
    <item>
      <name>Music Controls</name>
      <item>
        <name>Music Controls F7...F9</name>
        <appendix>F7 Music Previous</appendix>
        <appendix>F8 Play/Pause Music</appendix>
        <appendix>F9 Music Next</appendix>
        <identifier>private.insert_fn_fkey_to_music_controls</identifier>
        <autogen>__KeyToKey__ KeyCode::F7, ModifierFlag::FN, ConsumerKeyCode::MUSIC_PREV</autogen>
        <autogen>__KeyToKey__ KeyCode::F8, ModifierFlag::FN, ConsumerKeyCode::MUSIC_PLAY</autogen>
        <autogen>__KeyToKey__ KeyCode::F9, ModifierFlag::FN, ConsumerKeyCode::MUSIC_NEXT</autogen>
      </item>
    </item>
    <item>
      <name>Speaker Controls</name>
      <item>
        <name>Volume Up/Down/Mute</name>
        <appendix>F10 to Mute</appendix>
        <appendix>F11 to Volume Down</appendix>
        <appendix>F12 to Volume Up</appendix>
        <identifier>private.insert_fn_fkey_to_volume_adjust</identifier>
        <autogen>__KeyToKey__ KeyCode::F10, ModifierFlag::FN, ConsumerKeyCode::VOLUME_MUTE</autogen>
        <autogen>__KeyToKey__ KeyCode::F11, ModifierFlag::FN, ConsumerKeyCode::VOLUME_DOWN</autogen>
        <autogen>__KeyToKey__ KeyCode::F12, ModifierFlag::FN, ConsumerKeyCode::VOLUME_UP</autogen>
      </item>
    </item>
  </item>
</root>

Above config works when I press F8 it will play/pause music. However since my leopold fc660c doesn't have F1...F12 keys by default I need to press FN+8 so it acts as F8.

If I use my configuration above I would loose the functionality for F8 keys if I ever need to use it.

So I am asking is it possible to have INSERT + 8 act as F8 ??

Hope this make sense...

thanks

lanox commented 7 years ago

Update: Only way I got it to work, sort of is to press Insert+FN+F8 to make it act as F8, which is sort of what I want, I would just like to cut out FN step.

lanox commented 7 years ago

anyone. ??

dunkarooftop commented 7 years ago

few though here, I think there is better way to design the workflow, your current setup require finger moving in very award movement due to the location of the "fn" key and "insert" key

I would suggest try __SimultaneousKeyPresses__ example hold down "s" and "d" together for "previous track hold down "d" and "f" together for "next track" ...etc

or "Launcher mode" hold down "your own define key" (let use SLASH "\" here) holding down "\" tap "d" for "previous track holding dow "\" tap "f" for "next track" ...etc

I am using a HHKB with Space bar row removed custom mod. Happy Topre :)

Also if you still wanna stick with your current mod, I would not worry too much about "if I will need to use Function key in the future" thinking.... Function key is really depreciated in macOS no app really use it. Apple even remove them in the new macbook pro. in that case you can remove ModifierFlag::FN from the last 2 <item> you should able to trigger with "insert + 8" without FN key

lanox commented 7 years ago

@dunkarooftop thanks for the tip, I want to have insert +7, however if I change it to this

<autogen>__KeyToKey__ KeyCode::7, ConsumerKeyCode::MUSIC_PREV</autogen> it actually doesn't work nothing happens when I press Insert+7

If i have it like this. <autogen>__KeyToKey__ KeyCode::F7, ConsumerKeyCode::MUSIC_PREV</autogen> then just by pressing F7 it goes to previous song.

But I also loose the functionality of F7 which is little annoying I would prefer if by pressing F7 does nothing, but when I press Insert +7 to change to previous song.

Thanks

dunkarooftop commented 7 years ago

There is way to archive the way you want by not using F7 key. Using __KeyOverlaidModifier__ for it which you will turn "Insert" when combine with other key act as "hyper key (cmd+shift+opt+ctrl)" but when press alone will act as "Insert" and then define "hyper + 7" to trigger "previous track". This way we don't need to use F7 key.

Doc here https://pqrs.org/osx/karabiner/xml.html.en#syntax-__KeyOverlaidModifier__

<!--
 "Insert" when combine with other key act as "hyper key (cmd+shift+opt+ctrl)" but when press alone will act as "Insert" 
-->
<autogen>
  __KeyOverlaidModifier__
  KeyCode::A,
  KeyCode::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L, 
    KeyCode::PC_INSERT,
</autogen>

<autogen>
    __KeyToKey__
    KeyCode::7, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
    ConsumerKeyCode::MUSIC_PREV
</autogen>

Just tested and work fine :)

lanox commented 7 years ago

@dunkarooftop thanks, ugh dunno how I missed that one.

lanox commented 7 years ago

@dunkarooftop sorry to bother you again, I am not sure what a hell I am doing wrong. so this is my config.

<?xml version="1.0"?>
<root>
  <item>
    <name>Functional Keys F1...F12</name>
    <item>
      <name>Music Controls</name>
      <item>
        <name>Music Controls F7...F9</name>
        <appendix>F7 Music Previous</appendix>
        <appendix>F8 Play/Pause Music</appendix>
        <appendix>F9 Music Next</appendix>
        <identifier>private.insert_fn_fkey_to_music_controls</identifier>
        <autogen>__KeyToKey__ KeyCode::F7, KeyCode::HELP, ConsumerKeyCode::MUSIC_PREV</autogen>
        <autogen>__KeyToKey__ KeyCode::F8, KeyCode::HELP, ConsumerKeyCode::MUSIC_PLAY</autogen>
        <autogen>__KeyToKey__ KeyCode::F9, KeyCode::HELP, ConsumerKeyCode::MUSIC_NEXT</autogen>
      </item>
    </item>
    <item>
      <name>Speaker Controls</name>
      <item>
        <name>Volume Up/Down/Mute</name>
        <appendix>F10 to Mute</appendix>
        <appendix>F11 to Volume Down</appendix>
        <appendix>F12 to Volume Up</appendix>
        <identifier>private.insert_fn_fkey_to_volume_adjust</identifier>
        <autogen>__KeyToKey__ KeyCode::F10, KeyCode::HELP, ConsumerKeyCode::VOLUME_MUTE</autogen>
        <autogen>__KeyToKey__ KeyCode::F11, KeyCode::HELP, ConsumerKeyCode::VOLUME_DOWN</autogen>
        <autogen>__KeyToKey__ KeyCode::F12, KeyCode::HELP, ConsumerKeyCode::VOLUME_UP</autogen>
      </item>
    </item>
  </item>
</root>

and it works fine. However when I press F8 alone with out Insert it also acts as MUSIC_PLAY. How can I make it so it only works when I press Insert +F8 to act as MUSIC_PLAY and when I press F8 to act as F8.

thanks

dunkarooftop commented 7 years ago

All notes in code comment

What I did is turn "Insert" to become "Hyper (cmd+shift+opt+ctrl)" when pressed with other key, but act as "Insert" when press alone. Then turn "Hyper + Num_x" to all the music function. We do not use any "Function" key here. We do not need <name>Help to FN</name> from your 1st post.

The benefit of this is you can now also assign "Hyper (Insert)" + "key" to any of your app to use like "Keyboard Maestro" or "Alfred" like launcher...etc

More on Hyper key you can read the classic blog post from "Steve Losh" https://stevelosh.com/blog/2012/10/a-modern-space-cadet/#hyper

Let me know if it work out for you. cheers


<?xml version="1.0"?>
<root>

<!--
 "Insert" when combine with other key act as "hyper key (cmd+shift+opt+ctrl)" but when press alone will act as "Insert" 
-->

<!-- Now you can assign even more hotkeys with "Insert" + "keys" in other app, this don't just limited to use here -->
 <item>
    <name>Change "Insert" to "Hyper" key when pressed with other key</name>
    <identifier>private.change.intert.to.hyper</identifier>
        <autogen>
          __KeyOverlaidModifier__
        <!-- Go to event viewer see the code for your "insert key", replace next line and 3 line below to match it -->
          KeyCode::PC_INSERT,
          KeyCode::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L, 
          KeyCode::PC_INSERT,
        </autogen>
  </item>

    <!-- Set up a variable for our "Hyper key combo" for furture use, just save time to type and make code cleaner. HYPER = "ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L"-->
    <replacementdef>
      <replacementname>HYPER</replacementname>
      <replacementvalue>
        ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L 
      </replacementvalue>
    </replacementdef>

<!-- Note here I replace with all your F_x key to Num_x, We are not using any Functino key -->
  <item>
    <name>Functional Keys Num1...Num12</name>
    <item>
      <name>Music Controls</name>
      <item>
        <name>Music Controls Num7...Num9</name>
        <appendix>Num7 Music Previous</appendix>
        <appendix>Num8 Play/Pause Music</appendix>
        <appendix>Num9 Music Next</appendix>
        <identifier>private.insert_fn_fkey_to_music_controls</identifier>
        <autogen>
            __KeyToKey__ 
            KeyCode::KEY_7, {{ HYPER }}, 
            ConsumerKeyCode::MUSIC_PREV
        </autogen>
        <autogen>
            __KeyToKey__ 
            KeyCode::KEY_8, {{ HYPER }}, 
            ConsumerKeyCode::MUSIC_PLAY
        </autogen>
        <autogen>
            __KeyToKey__ 
            KeyCode::KEY_9, {{ HYPER }}, 
            ConsumerKeyCode::MUSIC_NEXT
        </autogen>
      </item>
    </item>

    <item>
      <name>Speaker Controls</name>
      <item>
        <name>Volume Up/Down/Mute</name>
        <appendix>Num10 to Mute</appendix>
        <appendix>Num11 to Volume Down</appendix>
        <appendix>Num12 to Volume Up</appendix>
        <identifier>private.insert_fn_fkey_to_volume_adjust</identifier>
        <autogen>
            __KeyToKey__ 
            KeyCode::KEY_0, {{ HYPER }}, 
            ConsumerKeyCode::VOLUME_MUTE
        </autogen>
        <autogen>
            __KeyToKey__ 
            KeyCode::MINUS, {{ HYPER }}, 
            ConsumerKeyCode::VOLUME_DOWN
        </autogen>
        <autogen>
            __KeyToKey__ 
            KeyCode::EQUAL, {{ HYPER }} , 
            ConsumerKeyCode::VOLUME_UP
        </autogen>
      </item>
    </item>
  </item>
</root>
lanox commented 7 years ago

Thanks so much @dunkarooftop I just got around changing this... I am not going to lie and say I understand how it works, but I am looking in to it now.

lanox commented 7 years ago

@dunkarooftop sorry to bother you again, I just updated my macos to sierra and the config above stoped working? thanks so much.

dunkarooftop commented 7 years ago

God, I feel so bad that I am the one breaking this news to you..... Karabiner doesn't work in Sierra. Apple rewrote the keyboard and mouse driver this OS update due to the touch bar support maybe...

There is Karabiner-Element which is very limited, but should be able to do what you want. You will need to convert the mod to json format which is Karabiner-Element use.

https://github.com/tekezo/Karabiner-Elements

Is this the only thing you modify on your system if yes I might have other solution for you

lanox commented 7 years ago

Hey @dunkarooftop I am sorry to be bothering you all the time. Just as I got it how I want it boom not working again hahah..

At this stage to be honest is the only thing I use on external keyboard.

dunkarooftop commented 7 years ago

What are the list of your media player ? It's a bit tricky but can be done with "Hammerspoon"

http://www.hammerspoon.org/

Give me the list I should be able to cook something up for you. Also you happen to use "Keyboard Maestro" or "Alfred" app?

lanox commented 7 years ago

@dunkarooftop thanks in advance, I use Alfred. I am not sure what you mean by "What are the list of your media player ?" , for music I use Spotify.

dunkarooftop commented 7 years ago

fallow instruction on this page to turn your "insert" to "hyper" (CMD+OPT+SHIFT+CTRL) He listed a couple ways see which one fit you better https://sayzlim.net/remapping-hyper-key-macos-sierra/

Then down load this Alfred workflow and assign all the hotkeys to your liking. https://github.com/dvjones89/alfred-media-keys