-
Notifications
You must be signed in to change notification settings - Fork 0
/
tapdance.c
47 lines (40 loc) · 1.49 KB
/
tapdance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include QMK_KEYBOARD_H
#include "keymap.h"
static void sentence_end(tap_dance_state_t *state, void *user_data) {
switch (state->count) {
// Double tapping TD_DOT produces
// ". <one-shot-shift>" i.e. dot, space and capitalize next letter.
// This helps to quickly end a sentence and begin another one
// without having to hit shift.
case 2:
/* Check that Shift is inactive */
if (!(get_mods() & MOD_MASK_SHIFT)) {
tap_code(KC_SPC);
/* Internal code of OSM(MOD_LSFT) */
add_oneshot_mods(MOD_BIT(KC_LEFT_SHIFT));
} else {
// send ">" (KC_DOT + shift → ">")
tap_code(KC_DOT);
}
break;
// Since `sentence_end` is called on each tap
// and not at the end of the tapping term,
// the third tap needs to cancel the effects
// of the double tap in order to get the expected
// three dots ellipsis.
case 3:
// remove the added space of the double tap case
tap_code(KC_BSPC);
// replace the space with a second dot
tap_code(KC_DOT);
// tap the third dot
tap_code(KC_DOT);
break;
// send KC_DOT on every normal tap of TD_DOT
default:
tap_code(KC_DOT);
}
};
tap_dance_action_t tap_dance_actions[] = {
[DOT_TD] = ACTION_TAP_DANCE_FN_ADVANCED(sentence_end, NULL, NULL),
};