diff options
| author | skullY <skullydazed@gmail.com> | 2017-08-06 20:57:57 -0700 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2017-08-16 15:47:20 -0400 |
| commit | 9d1a08e38ac9937cff4e61abfd0acc26ad5fdf4a (patch) | |
| tree | 352da3e60b219405be323306bcd67a6729107d61 /docs/feature_leader_key.md | |
| parent | 9b879b1267cd5cbebf4d73595c7ca4ed52fe5ef4 (diff) | |
| download | qmk_firmware-9d1a08e38ac9937cff4e61abfd0acc26ad5fdf4a.tar.gz qmk_firmware-9d1a08e38ac9937cff4e61abfd0acc26ad5fdf4a.zip | |
Doc updates from going through every file
Diffstat (limited to 'docs/feature_leader_key.md')
| -rw-r--r-- | docs/feature_leader_key.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/feature_leader_key.md b/docs/feature_leader_key.md new file mode 100644 index 000000000..bf4d5456d --- /dev/null +++ b/docs/feature_leader_key.md | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | # The Leader key: A new kind of modifier | ||
| 2 | |||
| 3 | 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. | ||
| 4 | |||
| 5 | That's what `KC_LEAD` does. Here's an example: | ||
| 6 | |||
| 7 | 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. | ||
| 8 | 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. | ||
| 9 | 3. Within your `matrix_scan_user` function, do something like this: | ||
| 10 | |||
| 11 | ``` | ||
| 12 | LEADER_EXTERNS(); | ||
| 13 | |||
| 14 | void matrix_scan_user(void) { | ||
| 15 | LEADER_DICTIONARY() { | ||
| 16 | leading = false; | ||
| 17 | leader_end(); | ||
| 18 | |||
| 19 | SEQ_ONE_KEY(KC_F) { | ||
| 20 | register_code(KC_S); | ||
| 21 | unregister_code(KC_S); | ||
| 22 | } | ||
| 23 | SEQ_TWO_KEYS(KC_A, KC_S) { | ||
| 24 | register_code(KC_H); | ||
| 25 | unregister_code(KC_H); | ||
| 26 | } | ||
| 27 | SEQ_THREE_KEYS(KC_A, KC_S, KC_D) { | ||
| 28 | register_code(KC_LGUI); | ||
| 29 | register_code(KC_S); | ||
| 30 | unregister_code(KC_S); | ||
| 31 | unregister_code(KC_LGUI); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | ``` | ||
| 36 | |||
| 37 | 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 | ||
