<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Leader, f => Types the below string</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SEND_STRING</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"QMK is awesome."</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h2id="basic-configuration"tabindex="-1">Basic Configuration <aclass="header-anchor"href="#basic-configuration"aria-label="Permalink to "Basic Configuration {#basic-configuration}""></a></h2><h3id="timeout"tabindex="-1">Timeout <aclass="header-anchor"href="#timeout"aria-label="Permalink to "Timeout {#timeout}""></a></h3><p>This is the amount of time you have to complete a sequence once the leader key has been pressed. The default value is 300 milliseconds, but you can change this by adding the following to your <code>config.h</code>:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LEADER_TIMEOUT</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 350</span></span></code></pre></div><h3id="per-key-timeout"tabindex="-1">Per-Key Timeout <aclass="header-anchor"href="#per-key-timeout"aria-label="Permalink to "Per-Key Timeout {#per-key-timeout}""></a></h3><p>Rather than relying on an incredibly high timeout for long leader key strings or those of us without 200 wpm typing skills, you can enable per-key timing to ensure that each key pressed provides you with more time to finish the sequence. This is incredibly helpful with leader key emulation of tap dance (such as multiple taps of the same key like C, C, C).</p><p>To enable this, add the following to your <code>config.h</code>:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LEADER_PER_KEY_TIMING</span></span></code></pre></div><p>After this, it's recommended that you lower your timeout below 300 ms:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LEADER_TIMEOUT</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 250</span></span></code></pre></div><p>Now, something like this won't seem impossible to do without a 1000 millisecond timeout:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">leader_sequence_three_keys</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(KC_C, KC_C, KC_C)) {</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SEND_STRING</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Per key timing is great!!!"</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3id="disabling-initial-timeout"tabindex="-1">Disabling Initial Timeout <aclass="header-anchor"href="#disabling-initial-timeout"aria-label="Permalink to "Disabling Initial Timeout {#disabling-initial-timeout}""></a></h3><p>Sometimes your leader key may be too far away from the rest of the keys in the sequence. Imagine that your leader key is one of your outer top right keys - you may need to reposition your hand just to reach your leader key. This can make typing the entire sequence on time hard difficult if you are able to type most of the sequence fast. For example, if your sequence is <code>Leader + asd</code>, typing <code>asd</code> fast is very easy once you have your hands in your home row, but starting the sequence in time after moving your hand out of the home row to reach the leader key and back is not.</p><p>To remove the stress this situation produces to your hands, you can disable the timeout just for the leader key. Add the following to your <code>config.h</code>:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LEADER_NO_TIMEOUT</span></span></code></pre></div><p>Now, after you hit the leader key, you will have an infinite amount of time to start the rest of the sequence, allowing you to properly position your hands to type the rest of the sequence comfortably. This way you can configure a very short <code>LEADER_TIMEOUT</code>, but still have plenty of time to position your hands.</p><h3id="strict-key-processing"tabindex="-1">Strict Key Processing <aclass="header-anchor"href="#strict-key-processing"aria-label="Permalink to "Strict Key Processing {#strict-key-processing}""></a></h3><p>By default, only the "tap keycode" portions of <ahref="./../mod_tap">Mod-Taps</a> and <ahref="./../feature_layers#switching-and-toggling-layers">Layer Taps</a> are added to the sequence buffer. This means if you press eg. <code>LT(3, KC_A)</code> as part of a sequence, <code>KC_A</code> will be added to the buffer, rather than the entire <code>LT(3, KC_A)</code> keycode.</p><p>This gives a more expected behaviour for most users, however you may want to change this.</p><p>To enable this, add the following to your <code>config.h</code>:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LEADER_KEY_STRICT_KEY_PROCESSING</span></span></code></pre></div><h2id="example"tabindex="-1">Example <aclass="header-anchor"href="#example"aria-label="Permalink to "Example {#example}""></a></h2><p>This example will play the Mario "One Up" sound when you hit <code>QK_LEAD</code> to start the leader sequence. When the sequence ends, it will play "All Star" if it completes successfully or "Rick Roll" you if it fails (in other words, no sequence matched).</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#ifdef</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_ENABLE</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h2id="keycodes"tabindex="-1">Keycodes <aclass="header-anchor"href="#keycodes"aria-label="Permalink to "Keycodes {#keycodes}""></a></h2><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>QK_LEADER</code></td><td><code>QK_LEAD</code></td><td>Begin the leader sequence</td></tr></tbody></table><h2id="api"tabindex="-1">API <aclass="header-anchor"href="#api"aria-label="Permalink to "API {#api}""></a></h2><h3id="api-leader-start-user"tabindex="-1"><code>void leader_start_user(void)</code><aclass="header-anchor"href="#api-leader-start-user"aria-label="Permalink to "`void leader_start_user(void)` {#api-leader-start-user}""></a></h3><p>User callback, invoked when the leader sequence begins.</p><hr><h3id="api-leader-end-user"tabindex="-1"><code>void leader_end_user(void)</code><aclass="header-anchor"href="#api-leader-end-user"aria-label="Permalink to "`void leader_end_user(void)` {#api-leader-end-user}""></a></h3><p>User callback, invoked when the leader sequence ends.</p><hr><h3id="api-leader-start"tabindex="-1"><code>void leader_start(void)</code><aclass="header-anchor"href="#api-leader-start"aria-label="Permalink to "`void leader_start(void)` {#api-leader-start}""></a></h3><p>Begin the leader sequence, resetting the buffer and timer.</p><hr><h3id="api-leader-end"tabindex="-1"><code>void leader_end(void)</code><aclass="header-anchor"href="#api-leader-end"aria-label="Permalink to "`void leader_end(void)` {#api-leader-end}""></a></h3><p>End the leader sequence.</p><hr><h3id="api-leader-sequence-active"tabindex="-1"><code>bool leader_sequence_active(void)</code><aclass="header-anchor"href="#api-leader-sequence-active"aria-label="Permalink to "`bool leader_sequence_active(void)` {#api-leader-sequence-active}""></a></h3><p>Whether the leader sequence is active.</p><hr><h3id="api-leader-sequence-add"tabindex="-1"><code>bool leader_sequence_add(uint16_t keycode)</code><aclass="header-anchor"href="#api-leader-sequence-add"aria-label="Permalink to "`bool leader_sequence_add(uint16_t keycode)` {#api-leader-sequence-add}""></a></h3><p>Add the given keycode to the sequence buffer.</p><p>If <code>LEADER_NO_TIMEOUT</code> is defined, the timer is reset if the buffer is empty.</p><h4id="api-leader-sequence-add-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-leader-sequence-add-arguments"aria-label="Permalink to "Arguments {#api-leader-sequence-add-arguments}""></a></h4><ul><li><code>uint16_t keycode</code><br> The keycode to add.</li></ul><h4id="api-leader-sequence-add-return"tabindex="-1">Return Value <aclass="header-anchor"href="#api-leader-sequence-add-return"aria-label="Permalink to "Return Value {#api-leader-sequence-add-return}""></a></h4><p><code>true</code> if the keycode was added, <code>false</code> if the buffer is full.</p><hr><h3id="api-leader-sequence-timed-out"tabindex="-1"><code>bool leader_sequence_timed_out(void)</code><aclass="header-anchor"href="#api-leader-sequence-timed-out"aria-label="Permalink to "`bool leader_sequence_timed_out(void)` {#api-leader-sequence-timed-out}""></a></h3><p>Whether the leader sequence has reached the timeout.</p><p>If <code>LEADER_NO_TIMEOUT</code> is defined, the buffer must also contain at least one key.</p><hr><h3id="api-leader-reset-timer"tabindex="-1"><code>bool leader_reset_timer(void)</code><aclass="header-anchor"href="#api-leader-reset-timer"aria-label="Permalink to "`bool leader_reset_timer(void)` {#api-leader-reset-timer}""></a></h3><p>Reset the leader sequence timer.</p><hr><h3id="api-leader-sequence-one-key"tabindex="-1"><code>bool leader_sequence_one_key(uint16_t kc)</code><aclass="header-anchor"href="#api-leader-sequence-one-key"aria-label="Permalinkto"`boolleader_sequen