Instead of indexing `Key` objects that have multiple names by each individual name, index by the set of names. This reduces the size of the default key dictionary by a factor of between 2 and 3, and as result also reduces reallocations/defragmentation. Instead of instantiating all module/extension keys by default, append them to the `maybe_key`-generator list.
16 lines
437 B
Python
16 lines
437 B
Python
from kmk.keys import KC, maybe_make_argumented_key
|
|
from kmk.modules.holdtap import HoldTap, HoldTapKeyMeta
|
|
|
|
|
|
class ModTap(HoldTap):
|
|
def __init__(self):
|
|
super().__init__()
|
|
KC._generators.append(
|
|
maybe_make_argumented_key(
|
|
validator=HoldTapKeyMeta,
|
|
names=('MT',),
|
|
on_press=self.ht_pressed,
|
|
on_release=self.ht_released,
|
|
)
|
|
)
|