summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskullydazed <skullydazed@users.noreply.github.com>2017-02-16 16:24:28 -0800
committerskullydazed <skullydazed@users.noreply.github.com>2017-02-16 16:24:28 -0800
commitac3753937a1f79a5ee919637b64ec56070d8ca78 (patch)
tree8882450cab872b7e67de818c8ec391c135dce9b1
parent53fde9a1ff66ee2286af2dd69ab16ae27d9c9f93 (diff)
downloadqmk_firmware-ac3753937a1f79a5ee919637b64ec56070d8ca78.tar.gz
qmk_firmware-ac3753937a1f79a5ee919637b64ec56070d8ca78.zip
Created Leader Key (markdown)
-rw-r--r--Leader-Key.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/Leader-Key.md b/Leader-Key.md
new file mode 100644
index 0000000000..bf4d5456d1
--- /dev/null
+++ b/Leader-Key.md
@@ -0,0 +1,37 @@
+# The Leader key: A new kind of modifier
+
+If you've ever used Vim, you know what a Leader key is. If not, you're about to discover a wonderful concept. :) Instead of hitting Alt+Shift+W for example (holding down three keys at the same time), what if you could hit a _sequence_ of keys instead? So you'd hit our special modifier (the Leader key), followed by W and then C (just a rapid succession of keys), and something would happen.
+
+That's what `KC_LEAD` does. Here's an example:
+
+1. Pick a key on your keyboard you want to use as the Leader key. Assign it the keycode `KC_LEAD`. This key would be dedicated just for this -- it's a single action key, can't be used for anything else.
+2. Include the line `#define LEADER_TIMEOUT 300` somewhere in your keymap.c file, probably near the top. The 300 there is 300ms -- that's how long you have for the sequence of keys following the leader. You can tweak this value for comfort, of course.
+3. Within your `matrix_scan_user` function, do something like this:
+
+```
+LEADER_EXTERNS();
+
+void matrix_scan_user(void) {
+ LEADER_DICTIONARY() {
+ leading = false;
+ leader_end();
+
+ SEQ_ONE_KEY(KC_F) {
+ register_code(KC_S);
+ unregister_code(KC_S);
+ }
+ SEQ_TWO_KEYS(KC_A, KC_S) {
+ register_code(KC_H);
+ unregister_code(KC_H);
+ }
+ SEQ_THREE_KEYS(KC_A, KC_S, KC_D) {
+ register_code(KC_LGUI);
+ register_code(KC_S);
+ unregister_code(KC_S);
+ unregister_code(KC_LGUI);
+ }
+ }
+}
+```
+
+As you can see, you have three function. you can use - `SEQ_ONE_KEY` for single-key sequences (Leader followed by just one key), and `SEQ_TWO_KEYS` and `SEQ_THREE_KEYS` for longer sequences. Each of these accepts one or more keycodes as arguments. This is an important point: You can use keycodes from **any layer on your keyboard**. That layer would need to be active for the leader macro to fire, obviously. \ No newline at end of file