-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Conditional module/extension #956
Comments
Thinking maybe something as simple as this? from kmk.keys import make_argumented_key
from kmk.modules import Module
class ConditionalKeyMeta:
def __init__(self, mods, key1, key2): # could use some type checks
self.mods = set(mods)
self.key1 = key1
self.key2 = key2
class ConditionalKey(Module):
def __init__(self):
make_argumented_key(
names=('CK',),
validator=ConditionalKeyMeta,
)
def during_bootup(self, keyboard):
return
def before_matrix_scan(self, keyboard):
return
def after_matrix_scan(self, keyboard):
return
def process_key(self, keyboard):
if is_pressed:
if self.meta.mods.intersection(keyboard.keys_pressed):
key = self.meta.key1
else:
key = self.meta.key2
return key
def before_hid_send(self, keyboard):
return
def after_hid_send(self, keyboard):
return
def on_powersave_enable(self, keyboard):
return
def on_powersave_disable(self, keyboard):
return Haven't made a module before, my knowledge of KMK is still new, and I'm currently unable to test if it works as my new keyboard I will put KMK on hasn't arrived just yet. |
You're basically asking for a "ModMorph" or "KeyOverride" kind of module. |
I have modified the code to make it work.
|
Is your feature request related to a problem? Please describe.
I use a lot of keys that depend on other keys being pressed, and the closest solution to this in KMK that I've found is to create a a bunch of custom key like this:
Describe the solution you'd like
A module/extension that makes this easier. Using the same example keys as above:
This might be very specific to my usecase, so it's understandable if it gets denied, I just want to clean up my messy main.py 😄.
The text was updated successfully, but these errors were encountered: