QMK 4 layers with 2 keys?

Can I get QMK to access 4 layers by holding (MO?) 0-2 keys? If so, what’s best practice for this? I’ve got a wicked hitchhiker’s thumb and I want to use it!

base(up,up)
layer2(down,up)
layer3(up,down)
layer4(down,down)

Pretty much all Plancks do that (lower, raise, adjust), so I would look at, say, keyboards/planck/keymaps/pok3r to see how it’s done.

Edit: actually that is a bad example, they do it in a roundabout way. What you want is simply to put MO(1) and MO(2) on the first layer, and then on layers 1 and 2 replace them with MO(3). That’s it.

You can even add one more layer, depending on the order in which those keys are pressed…

3 Likes

I was actually just about to post NOT to do it how the Planck does it, haha.

I’m actually not using the exact layer setup you mentioned, but I have a TG (toggle) layer that also has a layer key on it (via fall thru to the lower layer).

@wavebeem’s solution does not really address the question, but does show how to use MO.

@deshipu’s solution with stacked MO doesn’t work either. It seems to cause an undefined combination of all 3 layers, unless I am doing it wrong. I attached a QMK Configurator keymap file with an attempt at it (exactly as the OP asked it).

I am going to look into how Planks do it, but if someone knows how to do this in a simpler way, please let me know! Thanks :slight_smile:

EDIT: I was getting confused cause numpad wasn’t enabled while trying to use my fourth layer (MO(3)). Regardless, this keymap is here as an example for others.

Keymap:

{
  "version": 1,
  "notes": "",
  "documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
  "keyboard": "ferris/sweep",
  "keymap": "cusp_hold_layout",
  "layout": "LAYOUT_split_3x5_2",
  "layers": [
    [
      "KC_Q",
      "KC_W",
      "KC_E",
      "KC_R",
      "KC_T",
      "KC_Y",
      "KC_U",
      "KC_I",
      "KC_O",
      "KC_P",
      "KC_A",
      "KC_S",
      "KC_D",
      "KC_F",
      "KC_G",
      "KC_H",
      "KC_J",
      "KC_K",
      "KC_L",
      "KC_SCLN",
      "KC_Z",
      "KC_X",
      "KC_C",
      "KC_V",
      "KC_B",
      "KC_N",
      "KC_M",
      "KC_COMM",
      "KC_DOT",
      "KC_SLSH",
      "MO(1)",
      "KC_SPC",
      "OSM(MOD_LSFT)",
      "MO(2)"
    ],
    [
      "KC_ESC",
      "KC_PSCR",
      "KC_VOLD",
      "KC_VOLU",
      "KC_ESC",
      "KC_HOME",
      "KC_PGDN",
      "KC_PGUP",
      "KC_END",
      "KC_NO",
      "OSM(MOD_LGUI)",
      "OSM(MOD_LALT)",
      "OSM(MOD_LSFT)",
      "OSM(MOD_LCTL)",
      "KC_NO",
      "KC_LEFT",
      "KC_DOWN",
      "KC_UP",
      "KC_RGHT",
      "KC_BSPC",
      "KC_NO",
      "KC_NO",
      "KC_APP",
      "KC_TAB",
      "KC_NO",
      "KC_NO",
      "KC_ENT",
      "KC_NO",
      "KC_NO",
      "KC_DEL",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "MO(3)"
    ],
    [
      "KC_EXLM",
      "KC_AT",
      "KC_HASH",
      "KC_DLR",
      "KC_PERC",
      "KC_CIRC",
      "KC_AMPR",
      "KC_ASTR",
      "KC_EQL",
      "KC_COLN",
      "KC_GRV",
      "KC_TILD",
      "KC_LCBR",
      "KC_LPRN",
      "KC_LBRC",
      "KC_UNDS",
      "OSM(MOD_RCTL)",
      "OSM(MOD_RSFT)",
      "OSM(MOD_RALT)",
      "OSM(MOD_RGUI)",
      "KC_LT",
      "KC_GT",
      "KC_RCBR",
      "KC_RPRN",
      "KC_RBRC",
      "KC_BSLS",
      "KC_MINS",
      "KC_PLUS",
      "KC_SLSH",
      "KC_QUES",
      "MO(3)",
      "KC_NO",
      "KC_NO",
      "KC_NO"
    ],
    [
      "TO(4)",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_PAST",
      "KC_PMNS",
      "KC_P7",
      "KC_P8",
      "KC_P9",
      "KC_PPLS",
      "OSM(MOD_LGUI)",
      "OSM(MOD_LALT)",
      "OSM(MOD_LSFT)",
      "OSM(MOD_LCTL)",
      "KC_PSLS",
      "KC_P0",
      "KC_P4",
      "KC_P5",
      "KC_P6",
      "KC_PEQL",
      "QK_BOOT",
      "DB_TOGG",
      "KC_NO",
      "KC_NO",
      "KC_NUM",
      "KC_PDOT",
      "KC_P1",
      "KC_P2",
      "KC_P3",
      "KC_PENT",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO"
    ],
    [
      "KC_TRNS",
      "KC_W",
      "KC_E",
      "KC_R",
      "KC_T",
      "KC_Y",
      "KC_U",
      "KC_I",
      "KC_O",
      "KC_P",
      "KC_A",
      "KC_S",
      "KC_D",
      "KC_F",
      "KC_G",
      "KC_H",
      "KC_J",
      "KC_K",
      "KC_L",
      "KC_P",
      "KC_Z",
      "KC_X",
      "KC_C",
      "KC_V",
      "KC_B",
      "KC_N",
      "KC_M",
      "KC_COMM",
      "KC_DOT",
      "KC_SCLN",
      "KC_LSFT",
      "KC_SPC",
      "OSM(MOD_RSFT)",
      "MO(5)"
    ],
    [
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "KC_NO",
      "TO(0)",
      "KC_NO"
    ]
  ],
  "author": ""
}