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

Stuck keys troubleshooting #28

Closed
RedBearAK opened this issue Jun 14, 2022 · 25 comments
Closed

Stuck keys troubleshooting #28

RedBearAK opened this issue Jun 14, 2022 · 25 comments
Labels
bug Something isn't working

Comments

@RedBearAK
Copy link
Contributor

@joshgoebel

f8165f5
And try tuning the delay (manually) from 1s to lower and see if that helps... tranform line 200 or so... call_later.

Finally got a chance to do a fresh clone and try this. I set it to 0.2 and it seems to work a lot better. If I'm particularly quick it's still not quite fast enough to do what I expect. So I set it to 0.1.

It's safe to say I'm now confused a bit why the suspension time is even necessary if it can be set to such a short delay.

And still having issues with stuck modifiers. Seems to happen pretty reliably after using something like Cmd+Tab then moving to Cmd+Shift+Grave. Once the new window pops up, there is definitely at least one stuck modifier. I think it may be multiple keys because tapping just Alt (physical Super/Win) or RC (physical Alt) doesn't completely stop unexpected actions from occurring.

@joshgoebel
Copy link
Owner

joshgoebel commented Jun 14, 2022

after using something like Cmd+Tab then moving to Cmd+Shift+Grave

I don't know what that means exactly... can you be more specific? I need very explicit steps if you want me to try to reproduce over here. And if you might be interested in learning to write some units tests that'd be even better - you could just pass me a failing test in a PR - and then I could make it green...

It's safe to say I'm now confused a bit why the suspension time is even necessary if it can be set to such a short delay.

The lower you set it the more likely you are to trigger false key presses... if you set it to 0.1 and then you try to Cmd click but you aren't fast enough the "start menu" pops up on some distros, etc... so setting it too low just brings this problem back. #9

@joshgoebel
Copy link
Owner

I'm not sure 0 works but theoretically at 0 you should have the EXACT broken 0.4 behavior of pressing keys too soon... it's not exactly the same of course because I'm using a single delay for multimods since two different delays doesn't make a lot of sense in my book if they are going to be similar anyways.

@joshgoebel
Copy link
Owner

The great thing about that delay was that (until you found mouse clicking) the delay probably could have been MUCH LONGER... since most people don't press and hold modifiers on their own (and need that to trigger) - the next keys are usually soon to follow and we'll know what to do... so the delay effectively didn't matter... just so long as it wasn't too short.

Of course someone who was quite a slow typist might need a longer delay... but for me 1 second is an eternity to complete a keystroke.

@joshgoebel joshgoebel added the bug Something isn't working label Jun 14, 2022
@joshgoebel
Copy link
Owner

I think it may be multiple keys

You don't have to guess, that's why I added the DIAG key to tell you exactly what the internal state is.

@joshgoebel
Copy link
Owner

Only problem I see so far is if you start with a key that's persisted to output it gets stuck... ie, press and hold CMD past the 1s... then start a combo... and during the process it'll forget that it started by exerting itself - so it'll never get lifted when finished. So that's a start.

@joshgoebel
Copy link
Owner

joshgoebel commented Jun 14, 2022

You should try the exerted branch. Has the latest stuck/sticky fixes.

git fetch --all
git checkout exerted

It attempts to let each keystate track whether it has exerted itself on the output... and when the keystate is released it's responsible for releasing the output properly... hopefully this increased accountability will help.

@RedBearAK
Copy link
Contributor Author

Just ran into a complete loss of keyboard input issue. I had remembered to change the debug key to F8 but it didn't work. It's always worked recently, since I changed it from F16. Ended up having to close the terminal tab again.

I was just in here trying to type another comment in a different thread, tried to copy some text and paste it, and then couldn't type anything or switch windows or anything.

Will remember the DIAG dump next time. I have that on F7.

@joshgoebel
Copy link
Owner

I had remembered to change the debug key to F8 but it didn't work.

Make an issue and suggest an API and we can make those keys definable in your config. :) Perhaps diag_key and bailout_key or something...

@joshgoebel
Copy link
Owner

DIAG isn't likely to work if BAIL doesn't work... you'll need the log if you're having that level of issues... I just started running the branch myself... I wasn't yet - but all the tests are green. We'll see if I find any weird issues. Nothing so far.

@RedBearAK
Copy link
Contributor Author

No good on the exerted branch. Cmd+Tab is broken. No task switcher, no held key behavior.


(DD) WM_CLS 'gnome-text-editor' | DV 'AT Translated Set 2 keyboard' | KMAPS = [GNOME Text Editor, Anonymous keymap, General GUI, Wordwise - not vscode]
(DD)   COMBO: RCtrl-TAB => Alt-TAB [General GUI]
(DD) spent modifiers [<Key.RIGHT_CTRL: 97>]
(DD) resuspending keys
(DD) suspending keys [RCtrl<Key.RIGHT_CTRL>]
(OO) press LEFT_ALT
(OO) press TAB
(OO) release TAB
(OO) release LEFT_ALT

(II) in TAB (release)
(DD) on_key TAB release

(II) in LEFT_ALT (release)
(DD) on_key RIGHT_CTRL release
(DD) silent lift of spent mod RIGHT_CTRL

*** TRANSFORM  ***
are we suspended: False
_suspend_timer:
None
_last_key:
TAB
_states:
{}
_sticky:
{}
*** OUTPUT ***
_pressed_modifier_keys:
set()
_pressed_keys
set()


(II) in F7 (press)
(DD) on_key F7 press
(OO) press F7

(II) in F7 (release)
(DD) on_key F7 release
(OO) release F7
(EE) BAIL: Emergency shutdown requested.

@joshgoebel
Copy link
Owner

joshgoebel commented Jun 14, 2022

no held key behavior.

You didn't modify your config to support it... I copied you on #11.

And I'm at a loss, the output looks spot on:

(OO) press LEFT_ALT
(OO) press TAB
(OO) release TAB
(OO) release LEFT_ALT

Of course it would just switch apps, it might not pop up the task switcher if you didn't enable sticky/bind...

@RedBearAK
Copy link
Contributor Author

You didn't modify your config to support it

Oh, I haven't looked at that thread yet. Sounds like that will make my config incompatible with Kinto/xkeysnail already.

@RedBearAK
Copy link
Contributor Author

I did this in a separate keyszer.py config file and it seems to be working so far.

    K("Alt-Tab"): pass_through_key,                 # Default - Cmd Tab - App Switching Default
    K("RC-Tab"): [bind, K("Alt-Tab")],                      # Default - Cmd Tab - App Switching Default
    K("RC-Shift-Tab"): [bind, K("Alt-Shift-Tab")],          # Default - Cmd Tab - App Switching Default
    K("RC-Grave"): [bind, K("Alt-Grave")],                  # Default not-xfce4 - Cmd ` - Same App Switching
    K("RC-Shift-Grave"): [bind, K("Alt-Shift-Grave")],      # Default not-xfce4 - Cmd ` - Same App Switching

@RedBearAK
Copy link
Contributor Author

Not getting any stuck modifiers so far, even when transitioning from Cmd+Tab to Cmd+Shift+Tab or Cmd+Shift+Grave (while holding Cmd). That's when it would always happen with the other branch.

But, I'll have to go back in and set the delay down to 0.1 again for the clicking of links.

Of course someone who was quite a slow typist might need a longer delay... but for me 1 second is an eternity to complete a keystroke.

Hate to say this, but I have frequently held the Cmd key down for significant periods of time in macOS or Kinto while clicking a selection of links to open in background tabs. Shopping comparisons, opening a bunch of references from google links, things like that. I just keep that key held down for as long as I feel like I'm going to open another link, and it's never been a problem.

Then again, Kinto kills Unicode character entry by excessively emitting RC presses/releases. So... 🤷🏽

@joshgoebel
Copy link
Owner

joshgoebel commented Jun 14, 2022

Hate to say this, but I have frequently held the Cmd key down for significant periods of time in macOS or Kinto while clicking a selection of links to open in background tabs.

Yeah, that's not what I meant... I meant that 1 second is a long time to complete a single combo... most people don't need a full second to complete a single combo after hitting the first modifier. I was referring to the fact that if you're trying to type out a combo VERY SLOWLY and go past the 1s marker then it'll press the wrong keys on output. Though right now you get an extra second each time you hit a new mod, so actually it's even longer. :-)

Sounds like that will make my config incompatible with Kinto/xkeysnail already.

Yep but you could also define your own bind and just make it = None and then it wouldn't do anything on Kinto.

@joshgoebel
Copy link
Owner

You should be able to start tabbing backwards now as well while holding your task switcher open...

@joshgoebel
Copy link
Owner

I'll have to go back in and set the delay down to 0.1 again for the clicking of links.

Is 100ms long enough that the key always registers before your first click?

@RedBearAK
Copy link
Contributor Author

I’m not at my computer right now but I would venture to guess that with the necessary coordination between hands or the unusual reorienting of one hand to hold Cmd while tapping or clicking the touchpad, a delay of 100ms will work about 98% of the time.

@joshgoebel
Copy link
Owner

I kind of wish you had some software that would popup and annoy you if you didn't do it fast enough so you could test that side of things too. :) I wager 100ms isn't long enough for all users to find the second key in a combo and my thinking was for support requests better too long of a delay than too short of one...

Until the silly clicking issue messed it all up. :)

@RedBearAK
Copy link
Contributor Author

You should be able to start tabbing backwards now as well while holding your task switcher open...

Yes, starting with the Shift variants did seem to work as expected with this setup. Not just transitioning from starting with the forward variants.

@joshgoebel
Copy link
Owner

@RedBearAK If you're still having good results I'll merge the branch back into main.

@RedBearAK
Copy link
Contributor Author

@joshgoebel

This afternoon is actually the first time I've been able to get back on the laptop running keyszer, but it's been running the whole time since then and was acting fine when I started using the machine. I haven't yet experienced any stuck (or lost) keys that I know of, after doing various typing, app switching and cut/paste type operations. But I haven't been using it for long.

You'll have to remind me how to get back on the "main" branch (just git checkout main?), then I'll need to reapply my "fixes". The config options for the DAIG and DEBUG keys will minimize that.

Maybe you could add a config option for the sleep delay in output. output_delay_ms or something like that. Or maybe just an on/off kind of thing, since only the bare minimum 1ms delay seems to be necessary, when it is even necessary at all. Default to off, let the user turn it on if they have issues with macros.

@joshgoebel
Copy link
Owner

Maybe you could add a config option for the sleep delay in output.

See the... damn which thread it is... this is coming, but still trying to figure out what to do about all the delays...

@joshgoebel
Copy link
Owner

git checkout main

Though you may want to git stash and git stash pop to save and pop your stuff. (unless you commited it, then you might like cherrypick.

@RedBearAK
Copy link
Contributor Author

damn which thread it is... this is coming

Oh, what a tangled web of threads we weave... 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants