Is there a more concise way to write this in Keyman Keyboard Language?

Hi all,
I’ve been using Keyman Developer for ~6 hours and around half of that was me figuring out how to get a nice workflow on my Mac through Virtualbox, so forgive me if this is a noob question. Is there a more concise way to write the below code (specifically the three repeats for the capital letter)?

platform('mac native') + [NCAPS ALT K_Q] > U+0153 c oe
+ [NCAPS RALT K_Q] > U+0153 c oe
platform('mac native') + [ALT SHIFT K_Q] > U+0152 c OE
+ [RALT SHIFT K_Q] > U+0152 c OE
platform('mac native') + [CAPS ALT K_Q] > U+0152 c OE
+ [CAPS RALT K_Q] > U+0152 c OE
platform('mac native') + [CAPS ALT SHIFT K_Q] > U+0152 c OE
+ [CAPS RALT SHIFT K_Q] > U+0152 c OE

Also, is it possible to match characters that are in a store but not in another store?

store(alphabet) 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsUuWwYyZz'
store(acute_precomp) 'AaCcEeGgIiKkLlMmNnOoPpRrSsUuWwYyZz'

So I’d want to match all the characters in ‘alphabet’ AND not in ‘acute_precomp’. I do know about range expansions but I haven’t used them yet and this is a pseudo-example so I didn’t want to go and verify its operationality.

Thank you!

@bs4ca311oi2p welcome to the community :smiley:

You can use a store along with any and index to reduce repetition:

store(OE) U+0153 U+0153 U+0152 U+0152

platform('mac native') + any(OEKey_mac) > index(OE, 2)
+ any(OEKey) > index(OE, 1)

Note for base layer and shifted keys, you can use and &casedkeys to reduce repetition further. But this is not currently supported for Alt or RAlt.

The proper way to do this is have a higher precedence rule that matches on acute_precomp, e.g.:

any(acute_precomp) + [K_QUOTE] > index(acute_precomp_out, 1)   c or `context` or whatever...
any(alphabet) + [K_QUOTE] > context U+0301

Because the rules are the same length, the earlier rule takes precedence over the later one and matches in the second rule are ignored.

1 Like

Thanks a lot for your response, Marc. It is very informative and helpful.

I didn’t make this clear in the excerpt but I’m actually doing a few ligatures and digraphs (hence why concision is an issue). Is it possible to only put the modifiers in the store and the key in another? Hopefully this conveys my idea:

store(capligmods_mac) [NCAPS ALT SHIFT] [CAPS ALT]
store(capligmods) [NCAPS RALT SHIFT] [CAPS RALT]
store(lowligmods_mac) [NCAPS ALT] [CAPS ALT SHIFT]
store(lowligmods) [NCAPS RALT] [CAPS ALT SHIFT]
store(ligkeys) 'wqy'
c                   ae     oe     ij
store(capligatures) U+0152 U+00C6 U+0132
store(lowligatures) U+0153 U+00E6 U+0133

platform('mac native') + any(capligmods_mac) + any(ligkeys) > index(capligatures, 3)
+ any(capligmods_mac) + any(ligkeys) > index(capligatures, 2)
platform('mac native') + any(lowligmods_mac) + any(ligkeys) > index(lowligatures, 3)
+ any(lowligmods_mac) + any(ligkeys) > index(lowligatures, 2)

Note that I’ve switched to a mnemonic layout since my original post. If I could get similar code to this to work, I’d also be able to use it for Eszett and Ezh (on S and Z, respectively).

I’ve got the acute accent (and many other diacritics) working exactly how I want them now. Thank you.

This is not currently possible in Keyman Developer, sorry!