Is it possible to switch layers through keystroke combinations?

I’m thinking of implementing something like
any(punctuation) + " " > switch to 'default' layer.

Is it possible to do this?

Yes, you can use the layer() statement to do this.

For the touch layout, is it possible to set the initially displayed layer to be SHIFT layer?

This is not currently possible.

You’d have to be tricky and rename your shift layer to ‘default’ and your default layer to ‘lowercase’ or something like that … which is kinda messy and I don’t really recommend it!

So, I have been trying to accomplish something like this:

+ [SHIFT K_SPACE] > ' ' set(&layer = "default")
or
if(&layer = 'shift') + [K_SPACE] > ' ' set(&layer = "default")

but for some reason they both don’t work. Do you know how I can achieve this, Marc?

I’m not sure – would probably need to see your keyboard source to determine why it’s not working.

The keyboard is in this test branch
https://github.com/bennylin/keyboards/tree/indonesian-suku-test
The relevant test code starts at line 278. Thank you for taking time helping solving this.
So I assume no other keyboard has tried this before? I thought this is a quite useful feature in some of the default keyboard (e.g. Google keyboard)

Sorry it took me so long to get to this – too many things happening!

The issue ends up being straightforward, fortunately: you have a rule earlier in your keyboard which take precedence, on line 49:

+ [SHIFT K_SPACE] > $ZWS c if one do not wish the above accented letters

Because of this, the new rules never end up getting fired.

1 Like

Thanks for helping debugging it. I’m still trying to wrap my head up around the difference between (&layer = ‘shift’), [SHIFT …], touch layout, physical, and all that.

1 Like

Okay, I’ve written up the ‘initial layer’ concept which we’ve discussed various times in the past but never documented. See https://github.com/keymanapp/keyman/issues/2760. It won’t happen immediately and may not look exactly like that when it does, but we’ll plan for it to happen.