const__pageData=JSON.parse(`{"title":"How to Customize Your Keyboard's Behavior","description":"","frontmatter":{},"headers":[],"relativePath":"custom_quantum_functions.md","filePath":"custom_quantum_functions.md","lastUpdated":null}`);
const_hoisted_1=/* @__PURE__ */createStaticVNode('<h1id="how-to-customize-your-keyboard-s-behavior"tabindex="-1">HowtoCustomizeYourKeyboard'sBehavior<aclass="header-anchor"href="#how-to-customize-your-keyboard-s-behavior"aria-label="Permalink to "How to Customize Your Keyboard's Behavior""></a></h1><p>Foralotofpeopleacustomkeyboardisaboutmorethansendingbuttonpressestoyourcomputer.Youwanttobeabletodothingsthataremorecomplexthansimplebuttonpressesandmacros.QMKhashooksthatallowyoutoinjectcode,overridefunctionality,andotherwisecustomizehowyourkeyboardbehavesindifferentsituations.</p><p>ThispagedoesnotassumeanyspecialknowledgeaboutQMK,butreading<ahref="./understanding_qmk">UnderstandingQMK</a>willhelpyouunderstandwhatisgoingonatamorefundamentallevel.</p><h2id="a-word-on-core-vs-keyboards-vs-keymap"tabindex="-1">AWordonCorevsKeyboardsvsKeymap<aclass="header-anchor"href="#a-word-on-core-vs-keyboards-vs-keymap"aria-label="Permalinkto"AWordonCorevsKeyboardsvsKeymap{#a-word-on-core-vs-keyboards-vs-keymap}""></a></h2><p>WehavestructuredQMKasahierarchy:</p><ul><li>Core(<code>_quantum</code>)<ul><li>Keyboard/Revision(<code>_kb</code>)<ul><li>Keymap(<code>_user</code>)</li></ul></li></ul></li></ul><p>Eachofthefunctionsdescribedbelowcanbedefinedwitha<code>_kb()</code>suffixora<code>_user()</code>suffix.Weintendforyoutousethe<code>_kb()</code>suffixattheKeyboard/Revisionlevel,whilethe<code>_user()</code>suffixshouldbeusedattheKeymaplevel.</p><p>WhendefiningfunctionsattheKeyboard/Revisionlevelitisimportantthatyour<code>_kb()</code>implementationcall<code>_user()</code>beforeexecutinganythingelse-otherwisethekeymaplevelfunctionwillneverbecalled.</p><h1id="custom-keycodes"tabindex="-1">CustomKeycodes<aclass="header-anchor"href="#custom-keycodes"aria-label="Permalinkto"CustomKeycodes""></a></h1><p>Byfarthemostcommontaskistochangethebehaviorofanexistingkeycodeortocreateanewkeycode.Fromacodestandpointthemechanismforeachisverysimilar.</p><h2id="defining-a-new-keycode"tabindex="-1">DefiningaNewKeycode<aclass="header-anchor"href="#defining-a-new-keycode"aria-label="Permalinkto"DefiningaNewKeycode""></a></h2><p>Thefirststeptocreatingyourowncustomkeycode(s)istoenumeratethem.Thismeansbothnamingthemandassigningauniquenumbertothatkeycode.RatherthanlimitcustomkeycodestoafixedrangeofnumbersQMKprovidesthe<code>SAFE_RANGE</code>macro.Youcanuse<code>SAFE_RANGE</code>whenenumeratingyourcustomkeycodestoguaranteethatyougetauniquenumber.</p><p>Hereisanexampleofenumerating2keycodes.Afteraddingthisblocktoyour<code>keymap.c</code>youwillbeabletouse<code>FOO</code>and<code>BAR</code>insideyourkeymap.</p><divclass="language-cvp-adaptive-theme"><buttontitle="CopyCode"class="copy"></button><spanclass="lang">c</span><preclass="shikishiki-themesgithub-lightgithub-darkvp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">enum</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">my_keycodes{</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">FOO</span><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SAFE_RANGE,</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BAR</span></span>\n<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span></code></pre></div><h2id="programming-the-behavior-of-any-keycode"tabindex="-1">ProgrammingtheBehaviorofAnyKeycode<aclass="header-anchor"href="#programming-the-behavior-of-any-keycode"aria-label="Permalinkto"ProgrammingtheBehaviorofAnyKeycode{#programming-the-behavio