Need Help with Shift Key Macro for Dead Key Emulation

Hey everyone,

I’m using a US-Alt keyboard layout, and I’m trying to set up my UHK to emulate a dead key for accents. Basically, I want my Shift key to work in two ways:

  • Quick Tap: Should activate an AltGr sticky effect, keeping AltGr active until the next key press.
  • Held Press: Just works like a regular Shift key.

Here’s what I have so far:

holdKey iLS                             // Hold Shift key normally
ifNotPlaytime 1000 {                     // Quick press and release check
    oneShot holdLayer fn2               // Switch to fn2 for next keypress
    break                               // Exit the macro
}
delayUntilRelease                       // Wait until the Shift key is released
releaseKey iLS                          // Normal Shift function on hold

I also set up a fn2 layer that’s like the base layer, but every keypress acts as if AltGr is held down. It’s mostly working great, but sometimes when I release Shift and then press another key quickly, it triggers the held behavior instead of just tapping.

I’m looking for any tips on how to tweak this or maybe a different approach to handle this scenario. Anything that might make this setup more reliable would be super helpful.

Thanks a bunch!

Using Agent and assigning the dead key you want and then choosing Shift as secondary function should work.

@rpnfan He wants a sticky AltGr on tap, and Shift as secondary. I don’t think you can assign that directly using Agent. It will need some kind of macro. I am just not sure how to implement the sticky AltGr, but I would start with

ifSecondary final holdKey iLS
# put the code for a sticky RA here, probably something like:
pressKey RA
# but how to release it after the next key?
1 Like

Ah, you’re right. I misread that.

Thank you! That, in conjunction with the one shot hold layer, works pretty well, actually.

ifSecondary final holdKey iLS
oneShot holdLayer fn2        // Switch to AltGr layer for the next keypress

After adjusting the timeout, this seems pretty usable.

If there is a way to save on the extra layer, that would be great, though.

I am not sure if you can oneShot holdKey RA to just hold the right alt (AltGr).

1 Like

I tried it and it works beautifully. Thanks!

My final config for anyone interested is now just:

ifSecondary final holdKey iLS
oneShot holdKey RA

For the left shift key, and the same replacing iLS with iRS for the right shift key.

3 Likes