mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 19:40:29 +08:00
[Docs] Correct logic of tap hold statement (#14992)
Co-authored-by: filterpaper <filterpaper@localhost>
This commit is contained in:
parent
463cb40e16
commit
57f63e43d8
|
@ -83,33 +83,30 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
|
||||||
### Changing hold function
|
### Changing hold function
|
||||||
|
|
||||||
Likewise, the same custom code can also be used to intercept the hold function to send custom user key code. The following example uses `LT(0, kc)` (layer-tap key with no practical use because layer 0 is always active) to add cut, copy and paste function to X,C and V keys when they are held down:
|
Likewise, similar custom code can also be used to intercept the hold function to send custom user key code. The following example uses `LT(0, kc)` (layer-tap key with no practical use because layer 0 is always active) to add cut, copy and paste function to X,C and V keys when they are held down:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case LT(0,KC_X):
|
case LT(0,KC_X):
|
||||||
if (record->tap.count && record->event.pressed) {
|
if (!record->tap.count && record->event.pressed) {
|
||||||
return true; // Return true for normal processing of tap keycode
|
|
||||||
} else if (record->event.pressed) {
|
|
||||||
tap_code16(C(KC_X)); // Intercept hold function to send Ctrl-X
|
tap_code16(C(KC_X)); // Intercept hold function to send Ctrl-X
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return true; // Return true for normal processing of tap keycode
|
||||||
case LT(0,KC_C):
|
case LT(0,KC_C):
|
||||||
if (record->tap.count && record->event.pressed) {
|
if (!record->tap.count && record->event.pressed) {
|
||||||
return true; // Return true for normal processing of tap keycode
|
|
||||||
} else if (record->event.pressed) {
|
|
||||||
tap_code16(C(KC_C)); // Intercept hold function to send Ctrl-C
|
tap_code16(C(KC_C)); // Intercept hold function to send Ctrl-C
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case LT(0,KC_V):
|
}
|
||||||
if (record->tap.count && record->event.pressed) {
|
|
||||||
return true; // Return true for normal processing of tap keycode
|
return true; // Return true for normal processing of tap keycode
|
||||||
} else if (record->event.pressed) {
|
case LT(0,KC_V):
|
||||||
|
if (!record->tap.count && record->event.pressed) {
|
||||||
tap_code16(C(KC_V)); // Intercept hold function to send Ctrl-V
|
tap_code16(C(KC_V)); // Intercept hold function to send Ctrl-V
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true; // Return true for normal processing of tap keycode
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue