make TapDance a module (#281)
* extract tapdance logic into a module * clean out old tapdance code * canonicalize key variable names * split _process_tap_dance into td_pressed and td_released * implement consistent argument order * update documentation * implement Module.process_key for key interception and modification * fix tapdance realesing instead of pressing * fix: default parameters in key handler * cleanup holdtap * add error handling to modules process_key * fix: key released too late Tapped keys didn't release on a "key released" event, but waited for a timeout. Resulted in, for example, modifiers applying to keys after the modifier was released. * fix lint/formatting * fix tap_time reference in modtap + minimal documentation * fix lint
This commit is contained in:
@@ -4,7 +4,10 @@ added to the modules list.
|
||||
|
||||
```python
|
||||
from kmk.modules.modtap import ModTap
|
||||
keyboard.modules.append(ModTap())
|
||||
modtap = ModTap()
|
||||
# optional: set a custom tap timeout in ms
|
||||
# modtap.tap_time = 300
|
||||
keyboard.modules.append(modtap)
|
||||
```
|
||||
|
||||
## Keycodes
|
||||
|
@@ -13,3 +13,4 @@ put on your keyboard
|
||||
when tapped, and modifier when held.
|
||||
- [Power](power.md): Power saving features. This is mostly useful when on battery power.
|
||||
- [Split](split_keyboards.md): Keyboards split in two. Seems ergonomic!
|
||||
- [TapDance](tapdance.md): Different key actions depending on how often it is pressed.
|
||||
|
@@ -23,6 +23,8 @@ keymap somewhere. The only limits on how many keys can go in the sequence are,
|
||||
theoretically, the amount of RAM your MCU/board has, and how fast you can mash
|
||||
the physical key. Here's your chance to use all that button-mash video game
|
||||
experience you've built up over the years.
|
||||
[//]: # (The button mashing part has been 'fixed' by a timeout refresh per)
|
||||
[//]: # (button press. The comedic sentiment is worth keeping though.)
|
||||
|
||||
**NOTE**: Currently our basic tap dance implementation has some limitations that
|
||||
are planned to be worked around "eventually", but for now are noteworthy:
|
||||
@@ -31,16 +33,23 @@ are planned to be worked around "eventually", but for now are noteworthy:
|
||||
currently "undefined" at best, and will probably crash your keyboard. For now,
|
||||
we strongly recommend avoiding `KC.MO` (or any other layer switch keys that
|
||||
use momentary switch behavior - `KC.LM`, `KC.LT`, and `KC.TT`)
|
||||
[//]: # (This also doesn't seem to be the case anymore; as long as the layer)
|
||||
[//]: # (is transparent to the tap dance key.)
|
||||
[//]: # (At least KC.MO is working as intended, other momentary actions haven't)
|
||||
[//]: # (been tested.)
|
||||
|
||||
Here's an example of all this in action:
|
||||
|
||||
```python
|
||||
from kmk.keycodes import KC
|
||||
from kmk.macros.simple import send_string
|
||||
from kmk.handlers.sequences import send_string
|
||||
from kmk.modules.tapdance import TapDance
|
||||
|
||||
keyboard = KMKKeyboard()
|
||||
|
||||
keyboard.tap_time = 750
|
||||
tapdance = TapDance()
|
||||
tapdance.tap_time = 750
|
||||
keyboard.modules.append(tapdance)
|
||||
|
||||
EXAMPLE_TD = KC.TD(
|
||||
KC.A, # Tap once for "a"
|
||||
|
Reference in New Issue
Block a user