Macro help: esc/mouse/lockmouse on capslock key

Goal:

  • tapKey escape if I tap the capslock key
  • mouse layer while I hold the capslock key
  • lock mouse layer if I double tap the capslock key

macro:

tapKey escape
ifDoubletap toggleLayer mouse
ifNotInterrupted holdLayer mouse

works fine for the mouse (pretty close to the default QWR setting for the capslock key)

doesn’t send excape tap if I tap the caplsock key

What’s a good way to do this?

Ok, I remember this being worked out a while back in this thread here.

TL;DR
It was a little tricky for everyone to figure out, and it has some quirks.

There’s a slight delay when activating holdLayer mouse, and tapKey escape. If it feels weird, you can tweak the timing by adjusting the timeoutIn 150 on the first line. Also, you get stuck on the Mouse layer when using the double-tap to lock, so you’ll need a second macro to untoggle the Mouse layer.

The first macro goes on your Base layer’s mouse (CAPS) key (assuming that’s where you want it):

ifGesture timeoutIn 150 $thisKeyId final toggleLayer mouse
ifHold final holdLayer mouse
tapKey escape

and the second macro goes on the Mouse layer’s mouse key to un-toggle the locked layer:

untoggleLayer

So anyway, I think that should do what you want.
:melting_face:

4 Likes

doesn’t send excape tap if I tap the caplsock key

It should be sending it every single time.

My guess is that the OS doesn’t register it because uhk activated it only very briefly.

To solve it, set keystroke delay in typing behavior to 10 ms.

Still, especially games like to poll keys states instead of queuing events. In that case you will need something like this in your macro:

pressKey escape
delayUntil 50
releaseKey escape

One more variant of the macro is:

holdLayer mouse
ifDoubletap final toggleLayer mouse
ifNotInterrupted tapKey escape

Phil’s version’s drawback is that it will introduce delays since it needs to wait to see if the key gets activated a second time.

This version’s drawback is that it always sends an escape on the first tap of the doubletap.

3 Likes

Thank you @pcooke9 and @kareltucek . I appreciate the comments. Agent isn’t able to load my keyboard’s config (“Hang tight” forever), so I am unable to try your suggestions out.

A quick note before I file an issue on GitHub: … I do not want escape to fire on the doubleTap that locks the mouse layer. Hopefully the intent is clear. If not, I can go into detail later.

1 Like

Then you want to use the macro that @pcooke9 suggested.

2 Likes