One key switch to two layers

In Keyman, is it possible for one key to be used to switch to two different layers at different times based on the context? For example, at layer “alt” the layer doesn’t switch until the user does. Now, when the user wants to switch the layer, can this one key be made to switch to “shift” layer at “Start of Sentence” and to switch to “default layer” in other cases?

Yes, this can be done by creating a rule for the key, rather than using the next layer field in the touch layout editor. Say you name the key T_SuperShift, then:

c Start of sentence detection examples
nul + [T_SuperShift] > layer("shift")
'. ' + [T_SuperShift] > context layer("shift")
'.  ' + [T_SuperShift] > context layer("shift")
c add more start of sentence matches here if you like...

c Not at start of sentence
+ [T_SuperShift] > layer("default")

Note that you can’t make these rules on the K_SHIFT key at this time – you have to give it a custom T_ key name.

1 Like

That works very fine. Thank you.