possible leader fix

This commit is contained in:
Kyle Brown
2020-11-09 10:08:07 -08:00
parent 1f0aa18a73
commit ab49e5edff
11 changed files with 10 additions and 309 deletions

View File

@@ -1,68 +0,0 @@
# Leader Key
The leader key acts as a prefix to a key sequence. These can be used to trigger macros quickly
without dedicated keys set to each function. For those of you who dislike key combos, such as
Ctrl+Shift+Esc, then this feature is for you. This is very much inspired from vim.
## Keycode
|Key |Description |
|-----------------------|---------------------------------------------------------------------|
|`KC.LEAD` |The [Leader key] |
# Enabling the extention
```python
from kmk.extensions.leader import Leader
from kmk.handlers.sequences import send_string
leader_ext = Leader(}
)
keyboard.extensions.append(leader_ext)
```
Leader key sequences can be as long or short as you like. The action be a keycode, or
can be things like unicode macros, or generic macros. The example below shows how you would
trigger task manager in Windows with a leader sequence.
1. Assign a key to KC.LEAD
2. Above your keymap, include a LEADER_DICTIONARY.
```python
from kmk.macros.simple import simple_key_sequence
# ...
leader_ext = Leader(
sequences={
'task': : simple_key_sequence([Modifiers.KC_LCTRL(Modifiers.KC_LSHIFT(Common.KC_ESC))])
}
)
keymap = [...KC.LEAD,...]
# ...
```
# Modes
1. LeaderMode.TIMEOUT (the default)
2. LeaderMode.ENTER
### Timeout Mode
Will expire after a timer and trigger the sequence that matches if any. The default timeout is 1000ms
### Enter Mode
Has no timeout. To end sequence press the enter key, or cancel and do nothing, press escape.
## Changing defaults
To change the mode or timeout, add them here
```python
from kmk.extensions.leader import Leader, LeaderMode
leader_ext = Leader(
mode=LeaderMode.ENTER,
timeout=1000
sequences={
'hello': send_string('hello world from kmk macros'),
}
)
```

View File

@@ -70,35 +70,6 @@ keymap = [...emoticons.BEER, emoticons.HAND_WAVE...]
> `kmk.types.AttrDict`, which you can think of as a read-only view over a
> dictionary adding attribute-based (dot-notation) access.
Remember from the Leader Mode documentation that leader sequences simply bind to
keys, so extrapolating this example out a bit, you can bind emojis to leader
sequences matching some name or mnemonic representing the sequence you're
looking to send. If you ever wanted to type `<Leader>fire` and see a fire emoji
on your screen, welcome home.
```python
from kmk.handlers.sequences import compile_unicode_string_sequences as cuss
emoticons = cuss({
# Emojis
'BEER': r'🍺',
'BEER_TOAST': r'🍻',
'FACE_THINKING': r'🤔',
'FIRE': r'🔥',
'FLAG_CA': r'🇨🇦',
'FLAG_US': r'🇺🇸',
})
keyboard.leader_dictionary = {
'beer': emoticons.BEER,
'beers': emoticons.BEER_TOAST,
'fire': emoticons.FIRE,
'uhh': emoticons.FACE_THINKING,
'fca': emoticons.FLAG_CA,
'fus': emoticons.FLAG_US,
}
```
Finally, if you need to send arbitrary unicode codepoints in raw form, that's
supported too, through `unicode_codepoint_sequence`.

View File

@@ -15,7 +15,7 @@ quickly, then tapped and held (both actions within the timeout window), the
letter "b" will be held down until the tap dance key is released.
To use this, you may want to define a `tap_time` value in your keyboard
configuration. This is an integer in milliseconds, and defaults to `300`.
configuration. This is an integer in milliseconds, and defaults to `300`.
You'll then want to create a sequence of keys using `KC.TD(KC.SOMETHING,
KC.SOMETHING_ELSE, MAYBE_THIS_IS_A_MACRO, WHATEVER_YO)`, and place it in your
@@ -32,10 +32,6 @@ are planned to be worked around "eventually", but for now are noteworthy:
we strongly recommend avoiding `KC.MO` (or any other layer switch keys that
use momentary switch behavior - `KC.LM`, `KC.LT`, and `KC.TT`)
- Super fancy stuff like sending a keypress only when the leader key is released
(perhaps based on how long the leader key was held) is **unsupported** - an
example use case might be "tap for Home, hold for Shift"
Here's an example of all this in action:
```python