qmk_firmware/tap_hold.html

167 lines
157 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Tap-Hold Configuration Options | QMK Firmware</title>
<meta name="description" content="Documentation for QMK Firmware">
<meta name="generator" content="VitePress v1.1.3">
<link rel="preload stylesheet" href="/assets/style.No8zk9aC.css" as="style">
<script type="module" src="/assets/app.D828SKzM.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.DyMmIvSC.js">
<link rel="modulepreload" href="/assets/chunks/theme.D-bb5p4x.js">
<link rel="modulepreload" href="/assets/tap_hold.md.DD8WTSla.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar has-sidebar top" data-v-ae24b3ad data-v-ccf7ddec><div class="wrapper" data-v-ccf7ddec><div class="container" data-v-ccf7ddec><div class="title" data-v-ccf7ddec><div class="VPNavBarTitle has-sidebar" data-v-ccf7ddec data-v-ab179fa1><a class="title" href="/" data-v-ab179fa1><!--[--><!--]--><!--[--><!--[--><!--[--><img class="VPImage dark logo" src="/qmk-logo-dark.svg" alt data-v-8426fc1a><!--]--><!--[--><img class="VPImage light logo" src="/qmk-logo-light.svg" alt data-v-8426fc1a><!--]--><!--]--><!--]--><span data-v-ab179fa1>QMK Firmware</span><!--[--><!--]--></a></div></div><div class="content" data-v-ccf7ddec><div class="content-body" data-v-ccf7ddec><!--[--><!--]--><div class="VPNavBarSearch search" data-v-ccf7ddec><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-ccf7ddec data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="./" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Home</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-ccf7ddec data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-ccf7ddec data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://reddit.com/r/olkb" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M 29 3 C 28.0625 3 27.164063 3.382813 26.5 4 C 25.835938 4.617188 25.363281 5.433594 25 6.40625 C 24.355469 8.140625 24.085938 10.394531 24.03125 13.03125 C 19.234375 13.179688 14.820313 14.421875 11.28125 16.46875 C 10.214844 15.46875 8.855469 14.96875 7.5 14.96875 C 6.089844 14.96875 4.675781 15.511719 3.59375 16.59375 C 1.425781 18.761719 1.425781 22.238281 3.59375 24.40625 L 3.84375 24.65625 C 3.3125 26.035156 3 27.488281 3 29 C 3 33.527344 5.566406 37.585938 9.5625 40.4375 C 13.558594 43.289063 19.007813 45 25 45 C 30.992188 45 36.441406 43.289063 40.4375 40.4375 C 44.433594 37.585938 47 33.527344 47 29 C 47 27.488281 46.6875 26.035156 46.15625 24.65625 L 46.40625 24.40625 C 48.574219 22.238281 48.574219 18.761719 46.40625 16.59375 C 45.324219 15.511719 43.910156 14.96875 42.5 14.96875 C 41.144531 14.96875 39.785156 15.46875 38.71875 16.46875 C 35.195313 14.433594 30.800781 13.191406 26.03125 13.03125 C 26.09375 10.546875 26.363281 8.46875 26.875 7.09375 C 27.164063 6.316406 27.527344 5.757813 27.875 5.4375 C 28.222656 5.117188 28.539063 5 29 5 C 29.460938 5 29.683594 5.125 30.03125 5.40625 C 30.378906 5.6875 30.785156 6.148438 31.3125 6.6875 C 32.253906 7.652344 33.695313 8.714844 36.09375 8.9375 C 36.539063 11.238281 38.574219 13 41 13 C 43.75 13 46 10.75 46 8 C 46 5.25 43.75 3 41 3 C 38.605469 3 36.574219 4.710938 36.09375 6.96875 C 34.3125 6.796875 33.527344 6.109375 32.75 5.3125 C 32.300781 4.851563 31.886719
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SFT_T</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_SPC):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> TAPPING_TERM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1250</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, KC_GRV):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 130</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> TAPPING_TERM;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="dynamic-tapping-term" tabindex="-1">Dynamic Tapping Term <a class="header-anchor" href="#dynamic-tapping-term" aria-label="Permalink to &quot;Dynamic Tapping Term {#dynamic-tapping-term}&quot;"></a></h3><p><code>DYNAMIC_TAPPING_TERM_ENABLE</code> is a feature you can enable in <code>rules.mk</code> that lets you use three special keys in your keymap to configure the tapping term on the fly.</p><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>QK_DYNAMIC_TAPPING_TERM_PRINT</code></td><td><code>DT_PRNT</code></td><td>Types the current tapping term, in milliseconds</td></tr><tr><td><code>QK_DYNAMIC_TAPPING_TERM_UP</code></td><td><code>DT_UP</code></td><td>Increases the current tapping term by <code>DYNAMIC_TAPPING_TERM_INCREMENT</code>ms (5ms by default)</td></tr><tr><td><code>QK_DYNAMIC_TAPPING_TERM_DOWN</code></td><td><code>DT_DOWN</code></td><td>Decreases the current tapping term by <code>DYNAMIC_TAPPING_TERM_INCREMENT</code>ms (5ms by default)</td></tr></tbody></table><p>Set the tapping term as usual with <code>#define TAPPING_TERM &lt;value&gt;</code> in <code>config.h</code> and add <code>DYNAMIC_TAPPING_TERM_ENABLE = yes</code> in <code>rules.mk</code>. Then, place the above three keys somewhere in your keymap and flash the new firmware onto your board.</p><p>Now, you can try using your dual-role keys, such as layer-taps and mod-taps, and use <code>DT_DOWN</code> and <code>DT_UP</code> to adjust the tapping term immediately. If you find that you frequently trigger the modifier of your mod-tap(s) by accident, for example, that&#39;s a sign that your tapping term may be too low so tap <code>DT_UP</code> a few times to increase the tapping term until that no longer happens. On the flip side, if you get superfluous characters when you actually intended to momentarily activate a layer, tap <code>DT_DOWN</code> to lower the tapping term. Do note that these keys affect the <em>global</em> tapping term, you cannot change the tapping term of a specific key on the fly.</p><p>Once you&#39;re satisfied with the current tapping term value, open <code>config.h</code> and replace whatever value you first wrote for the tapping term by the output of the <code>DT_PRNT</code> key.</p><p>It&#39;s important to update <code>TAPPING_TERM</code> with the new value because the adjustments made using <code>DT_UP</code> and <code>DT_DOWN</code> are not persistent.</p><p>The value by which the tapping term increases or decreases when you tap <code>DT_UP</code> and <code>DT_DOWN</code> can be configured in <code>config.h</code> with <code>#define DYNAMIC_TAPPING_TERM_INCREMENT &lt;new value&gt;</code>. Note that the tapping term is <em>not</em> modified when holding down the tap term keys so if you need to, for example, decrease the current tapping term by 50ms, you cannot just press down and hold <code>DT_DOWN</code>; you will have to tap it 10 times in a row with the default increment of 5ms.</p><p>If you need more flexibility, nothing prevents you from defining your own custom keys to dynamically change the tapping term.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">enum</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> custom_dynamic_tapping_term_keys </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_UP_50 </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> SAFE_RANGE,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_DOWN_50,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_UP_X2,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_DOWN_X2,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">bool</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> process_record_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_UP_50:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (record</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event.pressed) {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> g_tapping_term </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 50</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_DOWN_50:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (record</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event.pressed) {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> g_tapping_term </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 50</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_UP_X2:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (record</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event.pressed) {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> g_tapping_term </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> DT_DOWN_X2:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (record</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event.pressed) {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> g_tapping_term </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span></code></pre></div><p>In order for this feature to be effective if you use per-key tapping terms, you need to make a few changes to the syntax of the <code>get_tapping_term</code> function. All you need to do is replace every occurrence of <code>TAPPING_TERM</code> in the <code>get_tapping_term</code> function by lowercase <code>g_tapping_term</code>. If you don&#39;t do that, you will still see the value typed by <code>DT_PRNT</code> go up and down as you configure the tapping term on the fly but you won&#39;t feel those changes as they don&#39;t get applied. If you can go as low as 10ms and still easily trigger the tap function of a dual-role key, that&#39;s a sign that you forgot to make the necessary changes to your <code>get_tapping_term</code> function.</p><p>For instance, here&#39;s how the example <code>get_tapping_term</code> shown earlier should look after the transformation:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_tapping_term</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SFT_T</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_SPC):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> g_tapping_term </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1250</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, KC_GRV):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 130</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> g_tapping_term;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>The reason is that <code>TAPPING_TERM</code> is a macro that expands to a constant integer and thus cannot be changed at runtime whereas <code>g_tapping_term</code> is a variable whose value can be changed at runtime. If you want, you can temporarily enable <code>DYNAMIC_TAPPING_TERM_ENABLE</code> to find a suitable tapping term value and then disable that feature and revert back to using the classic syntax for per-key tapping term settings. In case you need to access the tapping term from elsewhere in your code, you can use the <code>GET_TAPPING_TERM(keycode, record)</code> macro. This macro will expand to whatever is the appropriate access pattern given the current configuration.</p><h2 id="tap-or-hold-decision-modes" tabindex="-1">Tap-Or-Hold Decision Modes <a class="header-anchor" href="#tap-or-hold-decision-modes" aria-label="Permalink to &quot;Tap-Or-Hold Decision Modes&quot;"></a></h2><p>The code which decides between the tap and hold actions of dual-role keys supports three different modes, in increasing order of preference for the hold action:</p><ol><li><p>The default mode selects the hold action only if the dual-role key is held down longer than the tapping term. In this mode pressing other keys while the dual-role key is held down does not influence the tap-or-hold decision. In other words, this mode ignores interrupts.</p></li><li><p>The “permissive hold” mode, in addition to the default behavior, immediately selects the hold action when another key is tapped (pressed and then released) while the dual-role key is held down, even if this happens earlier than the tapping term. If another key is just pressed, but then the dual-role key is released before that other key (and earlier than the tapping term), this mode will still select the tap action.</p></li><li><p>The “hold on other key press” mode, in addition to the default behavior, immediately selects the hold action when another key is pressed while the dual-role key is held down, even if this happens earlier than the tapping term.</p></li></ol><p>Note that until the tap-or-hold decision completes (which happens when either the dual-role key is released, or the tapping term has expired, or the extra condition for the selected decision mode is satisfied), key events are delayed and not transmitted to the host immediately. The default mode gives the most delay (if the dual-role key is held down, this mode always waits for the whole tapping term), and the other modes may give less delay when other keys are pressed, because the hold action may be selected earlier.</p><h3 id="comparison" tabindex="-1">Comparison <a class="header-anchor" href="#comparison" aria-label="Permalink to &quot;Comparison {#comparison}&quot;"></a></h3><p>To better illustrate the tap-or-hold decision modes, let us compare the expected output of each decision mode in a handful of tapping scenarios involving a mod-tap key (<code>LSFT_T(KC_A)</code>) and a regular key (<code>KC_B</code>) with the <code>TAPPING_TERM</code> set to 200ms.</p><p>Note: &quot;<code>kc</code> held&quot; in the &quot;Physical key event&quot; column means that the key wasn&#39;t physically released yet at this point in time.</p><h4 id="distinct-taps" tabindex="-1">Distinct taps (AABB) <a class="header-anchor" href="#distinct-taps" aria-label="Permalink to &quot;Distinct taps (AABB) {#distinct-taps}&quot;"></a></h4><table><thead><tr><th>Time</th><th>Physical key event</th><th>Default</th><th><code>PERMISSIVE_HOLD</code></th><th><code>HOLD_ON_OTHER_KEY_PRESS</code></th></tr></thead><tbody><tr><td>0</td><td><code>LSFT_T(KC_A)</code> down</td><td></td><td></td><td></td></tr><tr><td>199</td><td><code>LSFT_T(KC_A)</code> up</td><td>a</td><td>a</td><td>a</td></tr><tr><td>210</td><td><code>KC_B</code> down</td><td>ab</td><td>ab</td><td>ab</td></tr><tr><td>220</td><td><code>KC_B</code> up</td><td>ab</td><td>ab</td><td>ab</td></tr></tbody></table><table><thead><tr><th>Time</th><th>Physical key eve
<span class="line"><span> +---------------|--------------------+</span></span>
<span class="line"><span> | +-------------|-------+ |</span></span>
<span class="line"><span> | | LT(2, KC_A) | | |</span></span>
<span class="line"><span> | +-------------|-------+ |</span></span>
<span class="line"><span> | | +--------------+ |</span></span>
<span class="line"><span> | | | KC_L | |</span></span>
<span class="line"><span> | | +--------------+ |</span></span>
<span class="line"><span> +---------------|--------------------+</span></span></code></pre></div><p>The above sequence would send a <code>KC_RGHT</code>, since <code>LT(2, KC_A)</code> is held longer than the <code>TAPPING_TERM</code>.</p><hr><p>Example sequence 2 (the <code>L</code> key is also mapped to <code>KC_RGHT</code> on layer 2):</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> TAPPING_TERM</span></span>
<span class="line"><span> +-----------------------------|------+</span></span>
<span class="line"><span> | +---------------+ | |</span></span>
<span class="line"><span> | | LT(2, KC_A) | | |</span></span>
<span class="line"><span> | +---------------+ | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> | | KC_L | | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> +-----------------------------|------+</span></span></code></pre></div><p>The above sequence will not send <code>KC_RGHT</code> but <code>KC_A</code> <code>KC_L</code> instead, since <code>LT(2, KC_A)</code> is not held longer than the <code>TAPPING_TERM</code>.</p><hr><p>Example sequence 3 (Mod Tap):</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> TAPPING_TERM</span></span>
<span class="line"><span> +---------------------------|--------+</span></span>
<span class="line"><span> | +-------------+ | |</span></span>
<span class="line"><span> | | SFT_T(KC_A) | | |</span></span>
<span class="line"><span> | +-------------+ | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> | | KC_X | | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> +---------------------------|--------+</span></span></code></pre></div><p>In the above sequence, <code>SFT_T(KC_A)</code> has been released before the end of its <code>TAPPING_TERM</code> and as such will be interpreted as <code>KC_A</code>, followed by any key event that happened after the initial press of <code>SFT_T(KC_A)</code>. In this instance, the output would be <code>KC_A</code> <code>KC_X</code>.</p><h3 id="permissive-hold" tabindex="-1">Permissive Hold <a class="header-anchor" href="#permissive-hold" aria-label="Permalink to &quot;Permissive Hold&quot;"></a></h3><p>The “permissive hold” mode can be enabled for all dual-role keys by adding the corresponding option to <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> PERMISSIVE_HOLD</span></span></code></pre></div><p>This makes tap and hold keys (like Layer Tap) work better for fast typists, or for high <code>TAPPING_TERM</code> settings.</p><p>If you press a dual-role key, tap another key (press and release) and then release the dual-role key, all within the tapping term, by default the dual-role key will perform its tap action. If the <code>PERMISSIVE_HOLD</code> option is enabled, the dual-role key will perform its hold action instead.</p><p>An example of a sequence that is affected by the “permissive hold” mode:</p><ul><li><code>LT(2, KC_A)</code> Down</li><li><code>KC_L</code> Down (the <code>L</code> key is also mapped to <code>KC_RGHT</code> on layer 2)</li><li><code>KC_L</code> Up</li><li><code>LT(2, KC_A)</code> Up</li></ul><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> TAPPING_TERM </span></span>
<span class="line"><span> +---------------------------|--------+</span></span>
<span class="line"><span> | +----------------------+ | |</span></span>
<span class="line"><span> | | LT(2, KC_A) | | |</span></span>
<span class="line"><span> | +----------------------+ | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> | | KC_L | | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> +---------------------------|--------+</span></span></code></pre></div><p>Normally, if you do all this within the <code>TAPPING_TERM</code> (default: 200ms), this will be registered as <code>al</code> by the firmware and host system. With the <code>PERMISSIVE_HOLD</code> option enabled, the Layer Tap key is considered as a layer switch if another key is tapped, and the above sequence would be registered as <code>KC_RGHT</code> (the mapping of <code>L</code> on layer 2). We could describe this sequence as a “nested tap” (the modified key&#39;s key down and key up events are “nested” between the dual-role key&#39;s key down and key up events).</p><p>However, this slightly different sequence will not be affected by the “permissive hold” mode:</p><ul><li><code>LT(2, KC_A)</code> Down</li><li><code>KC_L</code> Down (the <code>L</code> key is also mapped to <code>KC_RGHT</code> on layer 2)</li><li><code>LT(2, KC_A)</code> Up</li><li><code>KC_L</code> Up</li></ul><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> TAPPING_TERM </span></span>
<span class="line"><span> +---------------------------|--------+</span></span>
<span class="line"><span> | +-------------+ | |</span></span>
<span class="line"><span> | | LT(2, KC_A) | | |</span></span>
<span class="line"><span> | +-------------+ | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> | | KC_L | | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> +---------------------------|--------+</span></span></code></pre></div><p>In the sequence above the dual-role key is released before the other key is released, and if that happens within the tapping term, the “permissive hold” mode will still choose the tap action for the dual-role key, and the sequence will be registered as <code>al</code> by the host. We could describe this as a “rolling press” (the two keys&#39; key down and key up events behave as if you were rolling a ball across the two keys, first pressing each key down in sequence and then releasing them in the same order).</p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>The <code>PERMISSIVE_HOLD</code> option is not noticeable if you also enable <code>HOLD_ON_OTHER_KEY_PRESS</code> because the latter option considers both the “nested tap” and “rolling press” sequences like shown above as a hold action, not the tap action. <code>HOLD_ON_OTHER_KEY_PRESS</code> makes the Tap-Or-Hold decision earlier in the chain of key events, thus taking a precedence over <code>PERMISSIVE_HOLD</code>.</p></div><p>For more granular control of this feature, you can add the following to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> PERMISSIVE_HOLD_PER_KEY</span></span></code></pre></div><p>You can then add the following function to your keymap:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">bool</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_permissive_hold</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, KC_BSPC):</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Immediately select the hold action when another key is tapped.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Do not select the hold action when another key is tapped.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> false</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="hold-on-other-key-press" tabindex="-1">Hold On Other Key Press <a class="header-anchor" href="#hold-on-other-key-press" aria-label="Permalink to &quot;Hold On Other Key Press&quot;"></a></h3><p>The “hold on other key press” mode can be enabled for all dual-role keys by adding the corresponding option to <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> HOLD_ON_OTHER_KEY_PRESS</span></span></code></pre></div><p>This mode makes tap and hold keys (like Layer Tap) work better for fast typists, or for high <code>TAPPING_TERM</code> settings. Compared to the “permissive hold” mode, this mode selects the hold action in more cases.</p><p>If you press a dual-role key, press another key, and then release the dual-role key, all within the tapping term, by default the dual-role key will perform its tap action. If the <code>HOLD_ON_OTHER_KEY_PRESS</code> option is enabled, the dual-role key will perform its hold action instead.</p><p>An example of a sequence that is affected by the “hold on other key press” mode, but not by the “permissive hold” mode:</p><ul><li><code>LT(2, KC_A)</code> Down</li><li><code>KC_L</code> Down (the <code>L</code> key is also mapped to <code>KC_RGHT</code> on layer 2)</li><li><code>LT(2, KC_A)</code> Up</li><li><code>KC_L</code> Up</li></ul><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> TAPPING_TERM</span></span>
<span class="line"><span> +---------------------------|--------+</span></span>
<span class="line"><span> | +-------------+ | |</span></span>
<span class="line"><span> | | LT(2, KC_A) | | |</span></span>
<span class="line"><span> | +-------------+ | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> | | KC_L | | |</span></span>
<span class="line"><span> | +--------------+ | |</span></span>
<span class="line"><span> +---------------------------|--------+</span></span></code></pre></div><p>Normally, if you do all this within the <code>TAPPING_TERM</code> (default: 200ms), this will be registered as <code>al</code> by the firmware and host system. With the <code>HOLD_ON_OTHER_KEY_PRESS</code> option enabled, the Layer Tap key is considered as a layer switch if another key is pressed, and the above sequence would be registered as <code>KC_RGHT</code> (the mapping of <code>L</code> on layer 2).</p><p>For more granular control of this feature, you can add the following to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> HOLD_ON_OTHER_KEY_PRESS_PER_KEY</span></span></code></pre></div><p>You can then add the following function to your keymap:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">bool</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_hold_on_other_key_press</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, KC_BSPC):</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Immediately select the hold action when another key is pressed.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Do not select the hold action when another key is pressed.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> false</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h2 id="quick-tap-term" tabindex="-1">Quick Tap Term <a class="header-anchor" href="#quick-tap-term" aria-label="Permalink to &quot;Quick Tap Term&quot;"></a></h2><p>When the user holds a key after tapping it, the tapping function is repeated by default, rather than activating the hold function. This allows keeping the ability to auto-repeat the tapping function of a dual-role key. <code>QUICK_TAP_TERM</code> enables fine tuning of that ability. If set to <code>0</code>, it will remove the auto-repeat ability and activate the hold function instead.</p><p><code>QUICK_TAP_TERM</code> is set to <code>TAPPING_TERM</code> by default, which is the maximum allowed value for <code>QUICK_TAP_TERM</code>. To override its value (in milliseconds) add the following to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> QUICK_TAP_TERM</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 120</span></span></code></pre></div><p>Example:</p><ul><li><code>SFT_T(KC_A)</code> Down</li><li><code>SFT_T(KC_A)</code> Up</li><li><code>SFT_T(KC_A)</code> Down</li><li>(wait until tapping term expires...)</li></ul><p>With default settings, <code>a</code> will be sent on the first release, then <code>a</code> will be sent on the second press allowing the computer to trigger its auto repeat function until the key is released.</p><p>With <code>QUICK_TAP_TERM</code> configured, the timing between <code>SFT_T(KC_A)</code> up and <code>SFT_T(KC_A)</code> down must be within <code>QUICK_TAP_TERM</code> to trigger auto repeat. Otherwise the second press will be sent as a Shift. If <code>QUICK_TAP_TERM</code> is set to <code>0</code>, the second press will always be sent as a Shift, effectively disabling auto-repeat.</p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p><code>QUICK_TAP_TERM</code> timing will also impact anything that uses tapping toggles (Such as the <code>TT</code> layer keycode, and the One Shot Tap Toggle).</p></div><p>For more granular control of this feature, you can add the following to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> QUICK_TAP_TERM_PER_KEY</span></span></code></pre></div><p>You can then add the following function to your keymap:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_quick_tap_term</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SFT_T</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_SPC):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> QUICK_TAP_TERM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> QUICK_TAP_TERM;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>If <code>QUICK_TAP_TERM</code> is set higher than <code>TAPPING_TERM</code>, it will default to <code>TAPPING_TERM</code>.</p></div><h2 id="retro-tapping" tabindex="-1">Retro Tapping <a class="header-anchor" href="#retro-tapping" aria-label="Permalink to &quot;Retro Tapping&quot;"></a></h2><p>To enable <code>retro tapping</code>, add the following to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RETRO_TAPPING</span></span></code></pre></div><p>Holding and releasing a dual-function key without pressing another key will result in nothing happening. With retro tapping enabled, releasing the key without pressing another will send the original keycode even if it is outside the tapping term.</p><p>For instance, holding and releasing <code>LT(2, KC_SPC)</code> without hitting another key will result in nothing happening. With this enabled, it will send <code>KC_SPC</code> instead.</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> TAPPING_TERM</span></span>
<span class="line"><span> +-----------------|------------------+</span></span>
<span class="line"><span> | +---------------|-------+ |</span></span>
<span class="line"><span> | | LT(2, KC_SPC) | | |</span></span>
<span class="line"><span> | +---------------|-------+ |</span></span>
<span class="line"><span> | | |</span></span>
<span class="line"><span> | | |</span></span>
<span class="line"><span> | | |</span></span>
<span class="line"><span> +-----------------|------------------+</span></span></code></pre></div><p>For more granular control of this feature, you can add the following to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RETRO_TAPPING_PER_KEY</span></span></code></pre></div><p>You can then add the following function to your keymap:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">bool</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_retro_tapping</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, KC_SPC):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> false</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>If the programs you use bind an action to taps of modifier keys (e.g. tapping left GUI to bring up the applications menu or tapping left Alt to focus the menu bar), you may find that using retro-tapping falsely triggers those actions. To counteract this, you can define a <code>DUMMY_MOD_NEUTRALIZER_KEYCODE</code> in <code>config.h</code> that will get sent in between the register and unregister events of a held mod-tap key. That way, the programs on your computer will no longer interpret the mod suppression induced by retro-tapping as a lone tap of a modifier key and will thus not falsely trigger the undesired action.</p><p>Naturally, for this technique to be effective, you must choose a <code>DUMMY_MOD_NEUTRALIZER_KEYCODE</code> for which no keyboard shortcuts are bound to. Recommended values are: <code>KC_RIGHT_CTRL</code> or <code>KC_F18</code>. Please note that <code>DUMMY_MOD_NEUTRALIZER_KEYCODE</code> must be a basic, unmodified, HID keycode so values like <code>KC_NO</code>, <code>KC_TRANSPARENT</code> or <code>KC_PIPE</code> aka <code>S(KC_BACKSLASH)</code> are not permitted.</p><p>By default, only left Alt and left GUI are neutralized. If you want to change the list of applicable modifier masks, use the following in your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> MODS_TO_NEUTRALIZE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&lt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">mod_mask_1</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&lt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">mod_mask_2</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, ... }</span></span></code></pre></div><p>Examples:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> DUMMY_MOD_NEUTRALIZER_KEYCODE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> KC_RIGHT_CTRL</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Neutralize left alt and left GUI (Default value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> MODS_TO_NEUTRALIZE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_LEFT_ALT), </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_LEFT_GUI) }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Neutralize left alt, left GUI, right GUI and left Control+Shift</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> MODS_TO_NEUTRALIZE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_LEFT_ALT), </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_LEFT_GUI), </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_RIGHT_GUI), </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_LEFT_CTRL)</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MOD_BIT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_LEFT_SHIFT) }</span></span></code></pre></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>Do not use <code>MOD_xxx</code> constants like <code>MOD_LSFT</code> or <code>MOD_RALT</code>, since they&#39;re 5-bit packed bit-arrays while <code>MODS_TO_NEUTRALIZE</code> expects a list of 8-bit packed bit-arrays. Use <code>MOD_BIT(&lt;kc&gt;)</code> or <code>MOD_MASK_xxx</code> instead.</p></div><h3 id="retro-shift" tabindex="-1">Retro Shift <a class="header-anchor" href="#retro-shift" aria-label="Permalink to &quot;Retro Shift&quot;"></a></h3><p><a href="./features/auto_shift">Auto Shift,</a> has its own version of <code>retro tapping</code> called <code>retro shift</code>. It is extremely similar to <code>retro tapping</code>, but holding the key past <code>AUTO_SHIFT_TIMEOUT</code> results in the value it sends being shifted. Other configurations also affect it differently; see <a href="./features/auto_shift#retro-shift">here</a> for more information.</p><h2 id="why-do-we-include-the-key-record-for-the-per-key-functions" tabindex="-1">Why do we include the key record for the per key functions? <a class="header-anchor" href="#why-do-we-include-the-key-record-for-the-per-key-functions" aria-label="Permalink to &quot;Why do we include the key record for the per key functions?&quot;"></a></h2><p>One thing that you may notice is that we include the key record for all of the &quot;per key&quot; functions, and may be wondering why we do that.</p><p>Well, it&#39;s simple really: customization. But specifically, it depends on how your keyboard is wired up. For instance, if each row is actually using a row in the keyboard&#39;s matrix, then it may be simpler to use <code>if (record-&gt;event.key.row == 3)</code> instead of checking a whole bunch of keycodes. Which is especially good for those people using the Tap Hold type keys on the home row. So you could fine-tune those to not interfere with your normal typing.</p><h2 id="why-are-there-no-kb-or-user-functions" tabindex="-1">Why are there no <code>*_kb</code> or <code>*_user</code> functions?! <a class="header-anchor" href="#why-are-there-no-kb-or-user-functions" aria-label="Permalink to &quot;Why are there no `*_kb` or `*_user` functions?!&quot;"></a></h2><p>Unlike many of the other functions here, there isn&#39;t a need (or even reason) to have a quantum or keyboard-level function. Only user-level functions are useful here, so no need to mark them as such.</p></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-09de1c0f><!--[--><!--]--><!----><nav class="prev-next" data-v-09de1c0f><div class="pager" data-v-09de1c0f><a class="VPLink link pager-link prev" href="/features/tap_dance" data-v-09de1c0f><!--[--><span class="desc" data-v-09de1c0f>Previous page</span><span class="title" data-v-09de1c0f>Tap Dance</span><!--]--></a></div><div class="pager" data-v-09de1c0f><a class="VPLink link pager-link next" href="/features/tri_layer" data-v-09de1c0f><!--[--><span class="desc" data-v-09de1c0f>Next pa
<script>window.__VP_HASH_MAP__=JSON.parse("{\"changelog_20200530.md\":\"Dk-vRpTQ\",\"changelog_20200229.md\":\"DNsowwM1\",\"changelog_20200829.md\":\"CoqrOffn\",\"changelog_20210529.md\":\"CR1YNfZX\",\"cli_configuration.md\":\"CGSB128P\",\"config_options.md\":\"DvMeqlpB\",\"cli.md\":\"BLzAdA6l\",\"configurator_architecture.md\":\"DEFTvTlS\",\"cli_commands.md\":\"DGx-qNiE\",\"drivers_serial.md\":\"qxjytVdM\",\"drivers_spi.md\":\"tJVeIT7e\",\"drivers_uart.md\":\"BNBs-m3h\",\"drivers_ws2812.md\":\"D9E3Wb-Y\",\"changelog_20230827.md\":\"NSPhmB6l\",\"changelog_20231126.md\":\"D2Ok5QAf\",\"api_overview.md\":\"0FPaUsMb\",\"driver_installation_zadig.md\":\"CX9-BACt\",\"breaking_changes_history.md\":\"CkzdD6x8\",\"breaking_changes_instructions.md\":\"BAjIGeJb\",\"newbs_testing_debugging.md\":\"D-c7Gle_\",\"features_sequencer.md\":\"DkgqNCsQ\",\"drivers_apa102.md\":\"Qb-KXRpF\",\"one_shot_keys.md\":\"QR09rSb-\",\"arm_debugging.md\":\"BH-H2Ukz\",\"feature_userspace.md\":\"BsmY9yWw\",\"features_unicode.md\":\"CsON-fJH\",\"coding_conventions_c.md\":\"DdrpXBEh\",\"chibios_upgrade_instructions.md\":\"B5dMtL5R\",\"changelog_20201128.md\":\"7XXL02Bn\",\"changelog_20210828.md\":\"DNbHIuuM\",\"cli_development.md\":\"3xFA2OvS\",\"faq_keymap.md\":\"BsEmEZTo\",\"other_eclipse.md\":\"C-zqyJO9\",\"drivers_gpio.md\":\"C5PvyJVh\",\"other_vscode.md\":\"Di3vOySR\",\"changelog_20220226.md\":\"BWO5r_ec\",\"changelog_20240526.md\":\"iGLFD0SP\",\"features_space_cadet.md\":\"DmNfYRVJ\",\"faq_misc.md\":\"qGrhOTu4\",\"features_stenography.md\":\"Bb_IhUGl\",\"features_st7565.md\":\"MoajNurJ\",\"features_ps2_mouse.md\":\"CL_pA9sk\",\"features_split_keyboard.md\":\"mMTUzI5n\",\"feature_eeprom.md\":\"a0eoTZm7\",\"changelog_20220827.md\":\"DjPthqDk\",\"drivers_audio.md\":\"mqaz6p5N\",\"drivers_eeprom.md\":\"B_6soqar\",\"drivers_flash.md\":\"DhWcHp8S\",\"changelog_20221126.md\":\"DpbrnXeC\",\"drivers_i2c.md\":\"Cuj87reB\",\"api_development_overview.md\":\"Dcey4ntL\",\"features_wpm.md\":\"BYf-Xc1H\",\"flashing.md\":\"BSZF2RCy\",\"configurator_step_by_step.md\":\"GvmPtScT\",\"faq_build.md\":\"DL_WezA1\",\"api_docs.md\":\"CRoD6CbL\",\"platformdev_rp2040.md\":\"CYKYMDfc\",\"porting_your_keyboard_to_qmk.md\":\"CGlGdFj4\",\"faq_general.md\":\"BC3pFw4U\",\"data_driven_config.md\":\"BvLQ7P20\",\"custom_matrix.md\":\"DMnRw_5l\",\"faq_debug.md\":\"DuThValw\",\"pr_checklist.md\":\"BnrDXG2G\",\"documentation_templates.md\":\"Bhkum0wD\",\"drivers_adc.md\":\"DzU8txf8\",\"platformdev_selecting_arm_mcu.md\":\"aF4DUsvb\",\"getting_started_docker.md\":\"mz6HE4Bl\",\"features_caps_word.md\":\"BDQGM0-x\",\"configurator_troubleshooting.md\":\"BxGLPT8G\",\"features_swap_hands.md\":\"DOhgGQf9\",\"features_dip_switch.md\":\"DtBOdc98\",\"features_tri_layer.md\":\"DdnBVinw\",\"quantum_painter_lvgl.md\":\"DobNbSgA\",\"feature_debounce_type.md\":\"CUrSp0Iy\",\"features_dynamic_macros.md\":\"CrJ1vhBA\",\"quantum_painter_rle.md\":\"B07V3m-n\",\"features_encoders.md\":\"B2SX3hG2\",\"features_tap_dance.md\":\"CKLVpnIn\",\"getting_started_make_guide.md\":\"BjUuEnSh\",\"reference_glossary.md\":\"CXMuxToT\",\"features_grave_esc.md\":\"mUNEjUYS\",\"reference_keymap_extras.md\":\"-n_bLm78\",\"configurator_default_keymaps.md\":\"B3v8dlHd\",\"feature_layouts.md\":\"qcy8hNMO\",\"changelog_20230528.md\":\"nX9R48zP\",\"changelog_20240225.md\":\"B4-WrXj6\",\"features_audio.md\":\"DWNYte3W\",\"contributing.md\":\"DLsp4vSA\",\"features_hd44780.md\":\"15K40o_e\",\"features_key_lock.md\":\"IjFq9dYs\",\"features_key_overrides.md\":\"rVTP6kn9\",\"features_leader_key.md\":\"DBQTnBRh\",\"features_led_indicators.md\":\"CCZhjHe9\",\"features_mouse_keys.md\":\"C3P3pYuE\",\"features_midi.md\":\"u3tHPteB\",\"features_led_matrix.md\":\"DV31nHH-\",\"features_repeat_key.md\":\"C3eWDUWn\",\"features_rawhid.md\":\"bKKG3KCa\",\"features_oled_driver.md\":\"D9wJVdL1\",\"documentation_best_practices.md\":\"BtEjePaZ\",\"getting_started_github.md\":\"OYq7IT7B\",\"getting_started_introduction.md\":\"BOJreqSs\",\"features_secure.md\":\"BX7jFvW5\",\"features_rgblight.md\":\"DehQikiL\",\"hardware_drivers.md\":\"BUnx48D9\",\"h
</body>
</html>