SEND_STRING(), which will type out a string (i.e. a sequence of characters) for you. All ASCII characters that are easily translatable to a keycode are supported (e.g.
keymap.cfor a two-key keyboard:
process_record_userfunction, which is called whenever a key is pressed or released, to check if our custom keycode has been activated. If yes, we send the string
"QMK is the best thing ever!"to the computer via the
SEND_STRINGmacro (this is a C preprocessor macro, not to be confused with QMK macros). We return
trueto indicate to the caller that the key press we just processed should continue to be processed as normal (as we didn't replace or alter the functionality). Finally, we define the keymap so that the first button activates our macro and the second button is just an escape button.
process_record_user()function, is the
post_process_record_user()function. This runs after
process_recordand can be used to do things after a keystroke has been sent. This is useful if you want to have a key pressed before and released after a normal key, for instance.
F22is pressed before the keystroke is normally sent, and release it only after it's been released.
Home. You can send arbitrary keycodes by wrapping them in:
SS_TAP()presses and releases a key.
SS_DOWN()presses (but does not release) a key.
SS_UP()releases a key.
KC_HOME- note how the prefix is now
X_, and not
KC_. You can also combine this with other strings, like this:
KC_HOMEtap, and "LO" (spelling "LOVE" if on a newline).
SS_DELAY(msecs)will delay for the specified number of milliseconds.
KC_HOMEtap, and "LO" (spelling "LOVE" if on a newline, but delayed in the middle).
a(Left Control down,
a, Left Control up) - notice that they take strings (eg
"k"), and not the
send_string(), like this:
send_string(), but you can separate things out to different lines if needed:
<kc>keydown event to the computer. Some examples would be
KC_4, and even modifiers such as
register_codefunction, 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.
unregister_code(<kc>). This is useful if you want to send both the press and release events ("tap" the key, rather than hold it).
TAP_CODE_DELAYis defined (default 0), this function waits that many milliseconds before calling
unregister_code(<kc>). This can be useful when you are having issues with taps (un)registering.
KC_CAPS, it waits
TAP_HOLD_CAPS_DELAYmilliseconds instead (default 80), as macOS prevents accidental Caps Lock activation by waiting for the key to be held for a certain amount of time.
tap_code(<kc>), but with a
delayparameter for specifying arbitrary intervals before sending the unregister event.
register_code16(S(KC_5));instead of registering the mod, then registering the keycode.
KC_TAB, then wait for 1000ms. If the key is tapped again, it will send another
KC_TAB; if there is no tap,
KC_LALTwill be unregistered, thus allowing you to cycle through windows.