pqrs-org / Karabiner-archived

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

Ability to also add a modifier key launcher mode to LAUNCHER_MODE_V2 for clicking with trackpad? #778

Open nikitavoloboev opened 7 years ago

nikitavoloboev commented 7 years ago

You can activate this setting in Karabiner that will allow you to open apps from Karabiner.

2016-12-12 at 19 37

Would it be possible to modify it to add to it so that when O key is pressed and held and you press on the trackpad, it would act as a modifier key press (akin to holding cmd and pressing on the trackpad).

You can achieve this by setting o key as command key modifier but I want to keep the settings of launching applications or moving my mouse with MOUSE_KEYS_MODE v2 but also make modifier key presses when holding on a key and pressing the trackpad.

If such a thing would be possible to implement, it would be absolutely phenomenal.

nikitavoloboev commented 7 years ago

Can you perhaps make a key a modifier key, let's say I make 'a' key my control key, but I want to have 'a'+ space to send command + space instead of control + space. Is there a way to specify that in Karabiner?

dunkarooftop commented 7 years ago
<autogen>
    KeyCode::A, 
    KeyCode::CONTROL_R, 
</autogen>

<autogen>
    KeyCode::SPACE, ModifierFlag::CONTROL_R,
    KeyCode::SPACE, ModifierFlag::COMMAND_R,
</autogen>

That is a hack but will do the job. The order of the <autogen> here is important. doc: https://pqrs.org/osx/karabiner/xml.html.en#order

nikitavoloboev commented 7 years ago

Hey @dunkarooftop, this didn't seem to work for me as I have put it all under one item with the ordering you provided. I inserted this into the private.xml :

  <item>
      <name>make a control modifier</name>
      <identifier>control_modifier</identifier>
<autogen>
    KeyCode::A, 
    KeyCode::CONTROL_L 
</autogen>

<autogen>
    KeyCode::SPACE, ModifierFlag::CONTROL_R,
    KeyCode::SPACE, ModifierFlag::COMMAND_R
</autogen>
</item>

I also forgot to mention that I still want my 'a' key. That is when a is pressed alone quickly it will send an a symbol, but when you hold it and the press it with some other key it will be a control key that my trackpad also registers.

dunkarooftop commented 7 years ago

my typo, change line 6 from KeyCode::CONTROL_L to KeyCode::CONTROL_R,

nikitavoloboev commented 7 years ago

I have this code now :

  <item>
      <name>make a control modifier + a can still be pressed and a + space is a custom binding</name>
      <identifier>control_modifier</identifier>
<autogen>
    __KeyToKey__
    KeyCode::A, 
    KeyCode::CONTROL_R 
</autogen>

<autogen>
    __KeyToKey__
    KeyCode::SPACE, ModifierFlag::CONTROL_R,
    KeyCode::SPACE, ModifierFlag::COMMAND_R
</autogen>
</item>

This works to make a key into control key but I can't press a key as it doesn't register it. I also wish I could modify holding a and then pressing space to send a different combination.

So all in all, this is pretty close but I still want to be able to press a key and also I want to rebind a + space to send control + a.

This would be amazing. @dunkarooftop

dunkarooftop commented 7 years ago

Use __KeyOverlaidModifier__

Side effect, depends on type of typist, When typing fast if you smash keys when you encounter words like "at" if you smash "A" and "T" together it will send "CTRL" + "T". Also with this mod you will NOT be able to send "CTRL" + "SPACE" ever. It get auto convert to "CMD" + "SPACE".

<item>
    <name>make a control modifier + a can still be pressed and a + space is a custom binding</name>
    <identifier>control_modifier</identifier>
        <autogen>
            __KeyOverlaidModifier__
            KeyCode::A,
            <!-- When held with other key act as --> 
            KeyCode::CONTROL_R, 
            <!-- When tap ablone act as -->
            KeyCode::A,
        </autogen>

        <autogen>
            __KeyToKey__
            KeyCode::SPACE, ModifierFlag::CONTROL_R,
            KeyCode::SPACE, ModifierFlag::COMMAND_R, 
        </autogen>
</item>

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

nikitavoloboev commented 7 years ago

This is nearly perfect and what I want but it is kind of not usable.

As you say, you can't type things like 'at' in succession and this is a big deal breaker.

I wish it would work and have the same delay as launcher mode as you can write it out here :

  <item>
    <name>sticky a modifier</name>
    <identifier>private.launcher_mode_example</identifier>

    <!-- condition: turn on launcher mode only when the trigger key is pressed without other keys. -->
    <pressingphysicalkeys_lessthan>2</pressingphysicalkeys_lessthan>
    <modifier_not>
      ModifierFlag::COMMAND_L,
      ModifierFlag::COMMAND_R,
      ModifierFlag::CONTROL_L,
      ModifierFlag::CONTROL_R,
      ModifierFlag::FN,
      ModifierFlag::OPTION_L,
      ModifierFlag::OPTION_R,
      ModifierFlag::SHIFT_L,
      ModifierFlag::SHIFT_R,
    </modifier_not>

    <autogen>
      __KeyOverlaidModifier__
      KeyCode::A,

      <!--
          Use notsave.launcher_mode_v2 in order to be higher priority.
          Use ModifierFlag::MY_LAUNCHER_MODE for __DropAllKeys__.
      -->
      @begin
      KeyCode::VK_CONFIG_SYNC_KEYDOWNUP_notsave_private_launcher_mode, ModifierFlag::MY_LAUNCHER_MODE,
      @end

      @begin
      KeyCode::A,
      @end
    </autogen>
  </item>

  <item hidden="true">
    <identifier vk_config="true">notsave.private_launcher_mode</identifier>

    <autogen>
      __BlockUntilKeyUp__ KeyCode::A,
    </autogen>

       <autogen>
         __KeyToKey__
         KeyCode::SPACE,
         KeyCode::9, ModifierFlag::COMMAND_L, ModifierFlag::SHIFT_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L
       </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::0,
      KeyCode::0, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::SEMICOLON,
      KeyCode::SEMICOLON, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::BRACKET_LEFT,
      KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::BRACKET_RIGHT,
      KeyCode::BRACKET_RIGHT, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::R,
      KeyCode::R, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::S,
      KeyCode::S, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::1,
      KeyCode::1, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::DOT,
      KeyCode::DOT, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::COMMA,
      KeyCode::COMMA, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::2,
      KeyCode::2, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyToKey__
      KeyCode::3,
      KeyCode::3, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::Q,
      KeyCode::Q, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::W,
      KeyCode::W, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::E,
      KeyCode::E, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::T,
      KeyCode::T, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::Y,
      KeyCode::Y, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::U,
      KeyCode::U, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::I,
      KeyCode::I, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::O,
      KeyCode::O, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::P,
      KeyCode::P, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::S,
      KeyCode::S, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::D,
      KeyCode::D, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::F,
      KeyCode::F, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::G,
      KeyCode::G, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::H,
      KeyCode::H, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::Z,
      KeyCode::Z, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::X,
      KeyCode::X, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::C,
      KeyCode::C, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::V,
      KeyCode::V, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::B,
      KeyCode::B, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::N,
      KeyCode::N, ModifierFlag::CONTROL_L
  </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::M,
      KeyCode::M, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::K,
      KeyCode::K, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::J,
      KeyCode::J, ModifierFlag::CONTROL_L
    </autogen>

    <autogen>
      __KeyDownUpToKey__
      KeyCode::L,
      KeyCode::L, ModifierFlag::CONTROL_L
    </autogen>

  </item>

But with the added benefit that it is a native control key remap so that I can use my trackpad with a key pressed down and it will register it as control modifier.

Your solution is close but unusable due to this non existent delay for typing in a key with something else :(

dunkarooftop commented 7 years ago

I am confused, are you changing "A" to "CONTROL" and to trigger "Launcher Mode" as well ?

In Karabiner 2nd page "Parameter" you can change the setting and timing for __KeyOverlaidModifier__. You can play around with it.

dunkarooftop commented 7 years ago

BTW you can set variable in Karabiner to clean up the code, I see you use a lot of Hyper key. You can define this at the top of your private.xml

<replacementdef>
  <replacementname>HYPER</replacementname>
  <replacementvalue>
    ModifierFlag::COMMAND_L, ModifierFlag::SHIFT_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L
  </replacementvalue>
</replacementdef>

can call it by

{{ HYPER }}

Looking at your Launcher Mode for "A" you listed with "A" + "Space" send "9" + "Hyper" and you also want "A" + "Space" to send "Space" + "CMD" ? That doesn't make sense.... I am missing something here

dunkarooftop commented 7 years ago

also looking at your Launcher Mode code that you are mixing KeyToKey and KeyDownUpToKey I am guessing you are not sure what each do, it has to do how each key sequence press and release, like for the word "at" example

"A" down, "T" down, "A" up, "T" up act different to "A" down, "T" down, "T" up, "A" up in KeyDownUpToKey

That could be your answer to problem. refer details in doc: https://pqrs.org/osx/karabiner/xml.html.en#syntax-__KeyDownUpToKey__

nikitavoloboev commented 7 years ago

Well it is actually A + Space sending "9" + "Hyper" is what I want. CMD + space was just an example.

Essentially I want to have a be rebinded as control launcher key of sorts. That is pressing and holding a key and pressing some other key will send control + that other key.

Pressing control + space will send a custom combination, in my case "9 + hyper". And I want to use a key as normal when pressed alone with normal delay (the one that is currently is set for launcher key is what I want).

I just want to have a launcher key set on 'a' key as I have now but I want, when I press 'a' and hold for the trackpad to register 'a' as control key. I hope this makes sense and would be possible to do. This will be really life changing if it can be done. :)

nikitavoloboev commented 7 years ago

So do you think this would be possible to do @dunkarooftop?

dunkarooftop commented 7 years ago

My reply earlier with __KeyOverlaidModifier__ does what you want,

I do not recommend using alphabet characters for launcher mode or __KeyOverlaidModifier__...etc because you run into typing problem like "at" when you have "a" to trigger something or "th" when you use "t" to trigger something, specially with top n-gram characters (the most used character)

If you wanna keep your finger on the home row why not try use __SimultaneousKeyPresses__ and set when press "a" and "s" together act as control.

If you really wanna keep your finger on home row ditch "QWERY" go with "Colemak" https://colemak.com/ "Colemak-HD" https://colemakmods.github.io/mod-dh/compare.html (This is what I use, God I love it so much) "Workman" https://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/

Your finger will love you.

dunkarooftop commented 7 years ago

If you wanna dive into another world build/buy a custom mech keyboard you can compile it in C with tmk-firmware https://github.com/tmk/tmk_keyboard

So you are not limited to software, everything you want is with the keyboard and you can use it on different machine without install any software