Karabiner icon indicating copy to clipboard operation
Karabiner copied to clipboard

Combine KeyOverlaidModifier and KeyToKey for the same key

Open eipplusone opened this issue 7 years ago • 2 comments

I have the following snippet which remaps K to modifier when pressed with another key:

  <autogen>
    __KeyOverlaidModifier__
    KeyCode::K,

    KeyCode::VK_LAZY_SHIFT_R, ModifierFlag::K_TO_SHIFT,

    KeyCode::J,
  </autogen>


  <block>
    <modifier_only>ModifierFlag::K_TO_SHIFT</modifier_only>
    <autogen>__BlockUntilKeyUp__ KeyCode::K</autogen>
  </block>

I have another item that does the following:

<autogen>__KeyToKey__ KeyCode::K, ModifierFlag::OPTION_R, KeyCode::KEY_9, ModifierFlag::SHIFT_R</autogen>

It seems I can only either get one or the other, is there any way to combine the behavior?

eipplusone avatar May 04 '17 17:05 eipplusone

The order of the mod matter here, try this. I only modify K to J in the 2nd <autogen>

<autogen>
	__KeyToKey__ 
		KeyCode::J, ModifierFlag::OPTION_R, 
		KeyCode::KEY_9, ModifierFlag::SHIFT_R
</autogen>

OR (do not do both edit, just pick one of them) Come to think about it you can also just add ModifierFlag::NONE to the 1st mod

  <autogen>
    __KeyOverlaidModifier__
    KeyCode::K, ModifierFlag::NONE

    KeyCode::VK_LAZY_SHIFT_R, ModifierFlag::K_TO_SHIFT,

    KeyCode::J,
  </autogen>

To understand the difference refer to the doc https://pqrs.org/osx/karabiner/xml.html.en search for Order of <autogen> and ModifierFlag::NONE to see which fit your case better. (They do work differently)

dunkarooftop avatar May 14 '17 02:05 dunkarooftop

Now I look at it again you can just move the 2nd <autogen> above the 1st one would work too. Many different way to archive the same goal, still refer to doc to see which work better for you :)

dunkarooftop avatar May 14 '17 02:05 dunkarooftop