From 26f4e7031a643ce2760ae7b6df3bd2c79710451a Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 1 Oct 2018 17:53:47 -0700 Subject: [PATCH] Add tap_code function (#3784) * Add tap_code * formatting * Doc clarification * Rename variable to make more consistent --- docs/feature_macros.md | 4 ++++ tmk_core/common/action.h | 1 + 2 files changed, 5 insertions(+) diff --git a/docs/feature_macros.md b/docs/feature_macros.md index 673153081..ba5d91882 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -228,6 +228,10 @@ This sends the `` keydown event to the computer. Some examples would be `KC_ Parallel to `register_code` function, this sends the `` keyup event to the computer. If you don't use this, the key will be held down until it's sent. +### `tap_code();` + +This will send `register_code()` and then `unregister_code()`. 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. diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index 0322c73ed..833febe9c 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h @@ -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);