Skip to content
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

Keyboard: Add sticky keys functionality #3939

Closed
wants to merge 3 commits into from
Closed

Conversation

sypl
Copy link
Contributor

@sypl sypl commented Sep 19, 2018

Adding an option to reproduce sticky keys accessibility feature [https://en.wikipedia.org/wiki/Sticky_keys]

Tapping modifier keys in any sequence will add them to a register and apply them all with a keycode when next non-modifier keycode is sent through.

A second tap to a modifier will lock it, such that even after the keycode is sent with applied modifiers, locked modifiers will remain on the register.

Tapping shift five times toggles the feature on and off.

Adding an option to reproduce sticky keys accessibility feature
[https://en.wikipedia.org/wiki/Sticky_keys]

Tapping modifier keys in any sequence will add them to a register and apply
them all with a keycode when next non-modifier keycode is sent through.

A second tap to a modifier will lock it, such that even after the keycode
is sent with applied modifiers, locked modifiers will remain on the register.

Tapping shift five times toggles the feature on and off.
@drashna
Copy link
Member

drashna commented Sep 19, 2018

One Shot Mods does this already, I think: https://docs.qmk.fm/#/feature_advanced_keycodes?id=one-shot-keys

@sypl
Copy link
Contributor Author

sypl commented Sep 19, 2018

It's not possible to achieve this functionality with one shot mods, as far as I know. Mods clear after the post-mod key press. Additionally, there is a time limit as to how long after the mod is tapped that the feature applies.

No such restrictions apply here. Users can take as long as they need and apply up to all four mods. It's like a super mod one-shot.

This is a standard accessibility feature that typically has needed OS software to enable. I thought being able to carry it on your own keyboard would be really useful.

@drashna
Copy link
Member

drashna commented Sep 19, 2018

For OSM, mods only clear if ONESHOT_TIMEOUT is defined. If it's not defined, then they stay active until an appropriate keypress.

And if you hit another mod key, it will stack them, as well.

It's just that the functionality here is very similar, and I want to make sure that we're not adding another feature that heavily overlaps here.

@drashna
Copy link
Member

drashna commented Sep 19, 2018

ANd I'm starting to see what you're trying to do here.

👍

@sypl
Copy link
Contributor Author

sypl commented Sep 20, 2018

@drashna I didn't know that about the ONESHOT_TIMEOUT. Theoretically it gets us about 80% there to this functionality. Can't really lock mods though, at least not deliberately.

I tried it just now by placing the following keys on a clean keyboard:

#define SK_LALT OSM(MOD_LALT)
#define SK_LCTL OSM(MOD_LCTL)
#define SK_LSFT OSM(MOD_LSFT)
#define SK_LGUI OSM(MOD_LGUI)
#define SK_RALT OSM(MOD_RALT)
#define SK_RCTL OSM(MOD_RCTL)
#define SK_RSFT OSM(MOD_RSFT)
#define SK_RGUI OSM(MOD_RGUI)

The sticky mods behaviour seems OK, though there might a slight bug. Some mods do lock if you mash around the mods and then hit another key. I'm not sure how to reproduce this consistently yet, but it does happen.

@drashna
Copy link
Member

drashna commented Sep 20, 2018

Yeah, I think you can see my concern about overlapping features.

However, this does look distinct enough to me, that and it's definitely very neat. :)

@sypl
Copy link
Contributor Author

sypl commented Sep 20, 2018

For the OSM bug I mentioned just now, I'm wondering if it's related to the issue I raised previously: #3838

It certainly seems to be a similar behaviour, a layer/mod getting stuck when I piano over two OSL/OSM keys at the same time. The OSM one seems more difficult to reproduce, but it happens often enough that it seems a real issue. I think I may re-open that issue and even look in to it.

@sypl
Copy link
Contributor Author

sypl commented Sep 23, 2018

I think I can close this PR. It seems you can achieve a very similar functionality just by putting this in a keymap's config.h:

#define PREVENT_STUCK_MODIFIERS
#define ONESHOT_TAP_TOGGLE 2
#undef ONESHOT_TIMEOUT

It works pretty darn well. If I was 80% towards sticky keys functionality with my previous attempt at using OSM only, I'd say i'm up to 98% now.

I suspect there's still a subtle bug here somewhere. Mashing around on modifiers again I got in to a state where a modifier got stuck, with seemingly no way to clear it. I'll file an issue if I can reliably recreate it.

Some things are slightly different than how macOS implements sticky keys (can't talk about other OS, haven't really tried sticky keys on them), whereby tapping twice on a mod, no matter the the mod sequence, will toggle it. So SHIFT, ALT, SHIFT, GUI would lock SHIFT.

In contrast the setup with OSM with ONESHOT_TAP_TOGGLE set to 2 means that you have to hit the same modifier twice in succession. I'd actually argue that this is a more intuitive method for toggling a layer.

I'm glad there's a way of achieving this functionality without expanding the core. I wonder though whether there need exist a place for 'recipes' like this. There's a lot of cool functionality that people are creating with this firmware, but you have do dig through the keymaps in source to find them.

@sypl sypl closed this Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants