Macro key modifier

I’m attempting to setup the following macro:

Key held: hold fn4 layer
Key held along with shift key: hold mouse layer
Key double tapped: toggle mouse layer

Here’s my macro so far:

ifDoubletap toggleLayer mouse
else {
    ifShift holdLayer mouse
    ifNotShift holdLayer fn4
}

The doubletap is not working at all, holding the key does hold the fn4 layer, but the shift key only holds the mouse layer if it’s being held before I’ve hit this key. This makes sense since the ifShift is checking the status at runtime, but I’m uncertain how I’d get this to work the other way around (key then shift), or what about in both scenarios?

The doubletap is not working at all

I can’t reproduce this. Your macro works like a charm for me, including doubletap.

but the shift key only holds the mouse layer if it’s being held before I’ve hit this key

Well, that is obviously correct.

In order to react to <yourmacro> + shift, you can do:

ifDoubletap toggleLayer mouse
else {
    ifShift final holdLayer mouse
    ifGesture leftShift final holdLayer mouse
    ifGesture rightShift final holdLayer mouse
    ifNotShift final holdLayer fn4
}

(Assuming that your shifts are bound in normal positions.)

Edit: also, you can simplify it to:

ifDoubletap final toggleLayer mouse
ifShift final holdLayer mouse
ifGesture leftShift final holdLayer mouse
ifGesture rightShift final holdLayer mouse
holdLayer fn4

Unfortunately the doubletap still doesn’t seem to work for some reason. I’ve tried tapping slower and faster.

Additionally, is there any way to make this so that it holds the mouse layer while I’m holding shift, but if I release the shift key and the macro key is still held it reverts back to fn4? My use case here is fn4 is my arrow keys, but I’d like to be able to quickly jump in and out of the mousekeys

Unfortunately the doubletap still doesn’t seem to work for some reason. I’ve tried tapping slower and faster.

Well, reduce the testcase then:

ifDoubletap final tapKey d
tapKey a

Also, please do try to increase your doubletap timeout. E.g., by following snippet in a macro named $onInit:

set doubletapTimeout 500

Additionally, is there any way to make this so that it holds the mouse layer while I’m holding shift, but if I release the shift key and the macro key is still held it reverts back to fn4? My use case here is fn4 is my arrow keys, but I’d like to be able to quickly jump in and out of the mousekeys

Not with a reasonably simple syntax.

Of course, the macro language is Turing complete… you certainly can design a state machine that will react to presses and releases of both the keys and manage the layer “manually” (via toggleLayer instead of holdLayer).

This works without modifying the doubletap timeout:

ifDoubletap final tapKey d
tapKey a

It taps A, and if double tapped it taps D

The original macro however is still not enabling the mouse layer :thinking:

If you share your UserConfig, I will take a look…

I have actually uncovered two bugs in the firmware thanks to your report. Thanks!

Here is fixed firmware (development build): https://github.com/UltimateHackingKeyboard/firmware/files/13401500/uhk-firmware-10.4.0-rewrite_ifdoubletap.tar.gz

1 Like

Excellent, thank you for investigating!