Bind mod+key to Ralt+key

As generating umlauts with uhk config alone is finicky at best, I’m back to generating them via rightAlt+key combos. For example, say RA+;. How to map this combo onto mod layer, so mod+; generates RA+; while allowing to be shifted as well?

Tried following macro for a key on mod layer, but getting stuck on the shifted version:

pressKey rightAlt
ifShift suppressMods tapKeySeq S-semicolonAndColon  <--- can't get this bit to work
else tapKey semicolonAndColon
releaseKey rightAlt

Guess because of suppressMods RA needs to be sent as well, but RA-S-apostropheAndQuote is not a valid keyseq.
Any pointers?

Your macro is equivalent to:

holdKey RA-semicolonAndColon

Which can be entered directly in the key popover gui, so you don’t need a macro at all.

If that is not what you are after, then please let us lnow what scancode sequences you desire in which scenarios.

Modifiers will get composed automatically. (Your macro is removing shift and then adding it in again.)

Correct syntax for multiple mods in a single modmask is without that dash - LSRA-semicolonAndColon.

Thanks for the syntax pointers.

Your example still has the same issue in that shifted version does not work, as in it’ll simply produce a colon character.

On OS level the mapping is done by xmodmap, that converts (LS)RA-semicolonAndColon into umlauts:

! Set Right Alt as a Mode Switcher
keycode 108 = Mode_switch
keycode 47 = semicolon    colon      odiaeresis Odiaeresis

xev reports keycode 47 for semicolonAndColon key. showkey command shows keycode 39. showkey --scancodes shows 0x27 0xa7, guess one scancode for press and other for release?

Your example still has the same issue in that shifted version does not work, as in it’ll simply produce a colon character.

So both the modifiers are ignored, right? Edit: no, the right alt is ignored.

Does it work when you press that manually on the base layer?

It may be a timing issue - please try setting the keystroke delay in typing behavior Agent tab to 10ms.

Shift modifier is not ignored, as mod+shift+key produces colon character that requires a shift mod.
Keystroke delay doesn’t make a difference.

Using the actual RAlt key on base layer as opposed to mod layer works as expected.

Well, I have retested a similar-ish scenario, and it works fine for me. (I have my linux configured via xkb to write things like čČ via right alt, and that works fine when mapping holdKey RA-c in my fn layer. Binding via gui directly works fine too with both.)

I am not sure what is wrong, but it probably has to do with timing. You can try setting keystrokeDelay to some human-relevant value via $onInit. (Place set keystrokeDelay 200 command into a macro named $onInit, then see if that works. Then debug with showkey. )

1 Like

Set the dealy on $onInit and it started working. Then I removed the delay again and it continued working. Beats me, but it works – both macro and simple keypress config. Thanks!

That’s certainly weird.:upside_down_face: