]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add tap_code function (#3784)
authorDrashna Jaelre <drashna@live.com>
Tue, 2 Oct 2018 00:53:47 +0000 (17:53 -0700)
committerJack Humbert <jack.humb@gmail.com>
Tue, 2 Oct 2018 00:53:47 +0000 (20:53 -0400)
* Add tap_code

* formatting

* Doc clarification

* Rename variable to make more consistent

docs/feature_macros.md
tmk_core/common/action.h

index 67315308127f10cb381a708ab254a4f77cec1cda..ba5d91882fb7e8080ea31ace73fc64bc70969730 100644 (file)
@@ -228,6 +228,10 @@ This sends the `<kc>` keydown event to the computer. Some examples would be `KC_
 
 Parallel to `register_code` function, this sends the `<kc>` keyup event to the computer. If you don't use this, the key will be held down until it's sent.
 
+### `tap_code(<kc>);`
+
+This will send `register_code(<kc>)` and then `unregister_code(<kc>)`. This is useful if you want to send both the press and release events ("tap" the key, rather than hold it).
+
 ### `clear_keyboard();`
 
 This will clear all mods and keys currently pressed.
index 0322c73ed1e3fa08efbf21eb25f046a888be92b8..833febe9ce9bfa503759a1b5872bf57a33e368df 100644 (file)
@@ -88,6 +88,7 @@ void process_record(keyrecord_t *record);
 void process_action(keyrecord_t *record, action_t action);
 void register_code(uint8_t code);
 void unregister_code(uint8_t code);
+inline void tap_code(uint8_t code) { register_code(code); unregister_code(code); }
 void register_mods(uint8_t mods);
 void unregister_mods(uint8_t mods);
 //void set_mods(uint8_t mods);