Tap for single key, hold to access layer
1. Add new folder under Keymaps "tapholdlayer"
2. Copy keymap.cpp and keymap.h (from spacecadet)
3. Create a new set of keymap as format below. layer1, tap, hold...change accordingly.
void setupKeymap() {
uint32_t press[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRAVE,KC_1, KC_2, KC_3, KC_4, KC_5, KC_UNDS, \
KC_DEL ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_LCBR, \
KC_LSFT ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 , KC_SPC, \
KC_LCTL , KC_LGUI, KC_LALT, LAYER_3, LAYER_1, KC_SPC,_______ \
);
uint32_t layer1[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRAVE,KC_1, KC_2, KC_3, KC_4, KC_5, KC_UNDS, \
KC_DEL ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_LCBR, \
LAYER_1 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 , KC_SPC, \
KC_LCTL , KC_LGUI, KC_LALT, LAYER_3, LAYER_1, KC_SPC,_______ \
);
uint32_t tap[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRAVE,KC_1, KC_2, KC_3, KC_4, KC_5, KC_UNDS, \
KC_DEL ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_LCBR, \
LAYER_1 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 , KC_SPC, \
KC_LCTL , KC_LGUI, KC_LALT, LAYER_3, LAYER_1, KC_SPC,_______ \
);
uint32_t hold[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRAVE,KC_1, KC_2, KC_3, KC_4, KC_5, KC_UNDS, \
KC_DEL ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_LCBR, \
LAYER_1 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 , KC_SPC, \
KC_LCTL , KC_LGUI, KC_LALT, LAYER_3, LAYER_1, KC_SPC,_______ \
);
uint32_t singletap[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRAVE,KC_1, KC_2, KC_3, KC_4, KC_5, KC_UNDS, \
KC_DEL ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_LCBR, \
LAYER_1 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 , KC_SPC, \
KC_LCTL , KC_LGUI, KC_LALT, LAYER_3, LAYER_1, KC_SPC,_______ \
);
uint32_t doubletap[MATRIX_ROWS][MATRIX_COLS] =
KEYMAP( \
KC_GRAVE,KC_1, KC_2, KC_3, KC_4, KC_5, KC_UNDS, \
KC_DEL ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_LCBR, \
LAYER_1 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 , KC_SPC, \
KC_LCTL , KC_LGUI, KC_LALT, LAYER_3, LAYER_1, KC_SPC,_______ \
);
next part is:
do note the _L1/2/3/0, it is defined in keymap.h, eg. #define _QWERTY 0
4. change the following lines for new layers added for mod/tap
/*
* add the other layers on the regular presses.
*/
for (int row = 0; row < MATRIX_ROWS; ++row)
{
for (int col = 0; col < MATRIX_COLS; ++col)
{
//Method::Press Standard keypress
//Method::MT_TAP This key is sent once when the key is tapped.
//Method::MT_HOLD This key is sent once when the key is held.
//Method::DT_TAP This key is sent once when the key is tapped.
//Method::DT_DOUBLETAP This key is sent once when the key is tapped twice.
matrix[row][col].addActivation(_QWERTY, Method::MT_TAP, tap[row][col]);
matrix[row][col].addActivation(_QWERTY, Method::MT_HOLD, hold[row][col]);
matrix[row][col].addActivation(_L1, Method::PRESS, layer1[row][col]);
}
}