Change layers in Macros

Hi, could anyone help me?
I want to make a Macro which press a key(Key_Lang1) and change layer to the layer[KANA].
I fugured I can use ‘MACRODOWN(T(Key_Lang1)’ for press the key but how I change a current layer in the macro?

enum { MACRO_KANA;
}

(KANA layer is declared)

case MACRO_KANA:
if (keyToggledOn(keyState)){
return MACRODOWN(T(Key_Lang1));
//I can’t use LockLayer(KANA) here, can I?
}

I’m trying to set up a Japanese Kana keymap and struggling doing so. I have three more Kana layers to set for my keymap, but I need to figure out this first before making more layer!
Thanks!

You’re on the right track. LockLayer(KANA) is just like any other key, so you can just use

return MACRODOWN(Tr(Key_Lang1), Tr(LockLayer(KANA)));

to press both ‘keys’ in sequence whenever MACRO_KANA is pressed.

2 Likes

Thank you, it works!!! Looking at it, it makes so much sense.

Though I couldn’t back to QWERTY layer by using ‘LockLayer(QWERTY)’.
When I try to change the layer to QWERTY by using same macro(except the name of the layer), it remains in KANA layer.

Is there another way to back to default layer or do I need to release the KANA layer somehow? (Or I’m doing something wrong…)

Layers are a ‘stack’, rather than discrete ‘modes’, so what I think you want to do is to call LockLayer(KANA) again there.

You can think about LockLayer working like CapsLock just for layers rather than capital letters, if that makes any sense.

4 Likes

Thank you!!!
Now I can work on my Kana keymap. :kissing_cat:

2 Likes