kinto icon indicating copy to clipboard operation
kinto copied to clipboard

Alt key occasionally becomes "stuck"

Open leftbones opened this issue 1 year ago • 7 comments

I'm running into this issue probably 8-10 times a day in Windows 11, I don't use Linux frequently so I can't confirm if this issue carries over.

Occasionally, when I'm using Alt+Tab, the Alt key will get "stuck". It becomes immediately obvious, because when I let go of Alt, the window switcher thing stays open. The issue is resolved by just pressing the Alt key again, but considering how often it happens, it's become a real pain when I'm constantly switching through windows for my work.

leftbones avatar Apr 02 '23 21:04 leftbones

@leftbones

I've also run into this from time to time, and then at other times it doesn't seem to be a problem. It's a long-standing issue with AutoHotkey and other Windows keymappers, that doesn't seem to have a solid solution.

ChatGPT seems convinced that adding a couple of lines to the *tab block can help. I tried it out and they don't seem to do anything harmful. But I can't say yet whether it will have any effect on the task switcher getting stuck when that issue does appear. When I tried it, I wasn't having the stuck task switcher issue, so I can't say whether it made any difference at all.

; New AltTab and CtrlTab fix
*tab:: 
{
    ; Tertiary 
    if (GetKeyState("LCtrl", "P") AND GetKeyState("LShift", "P") = false) {
        ; Secondary
        ; Send {LCtrl down}{Secondary up}{tab}
        Send {LCtrl down}{LWin up}{tab}               ; WinModifiers
        KeyWait, tab
    ; Tertiary
    } else if (GetKeyState("LCtrl", "P") AND GetKeyState("LShift", "P")) {
        ; Secondary
        ; Send {LCtrl down}{Secondary up}{LShift down}{tab}
        Send {LCtrl down}{LWin up}{LShift down}{tab}     ; WinModifiers/CB
        KeyWait, tab
    ; Primary
   } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P") = false) {   ; WinModifiers/CB/IBM
        Send {LAlt down}{tab}
        KeyWait, tab
    ; Primary
   } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P")) { ; WinModifiers/CB/IBM
        Send {LAlt down}{LShift down}{tab}
        KeyWait, tab
    ; Secondary 
   } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) = false {     ; WinModifiers/CB
        return
    ; Secondary
    } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) {     ; WinModifiers/CB
        return
    } else {
        send {Blind}{tab}
        KeyWait, Tab
        Send {LAlt up}
    }
    return
}

It's the two lines after send {Blind}{tab} near the bottom that are new.

The only way to see if it will help is to try it for a significant period of time and see what happens.

RedBearAK avatar Apr 03 '23 07:04 RedBearAK

@RedBearAK that didn't work for me.

I have had this problem for years, but think I finally have a solution. This occurs very often (at least in my case) when using the Shift modifier to reverse the order of the window/tab switching. What's happening is, it's not releasing the keys in the correct order in the script because it's not explicitly sending key up command for all the keys in their respective conditional section.

So if you release one key before another, the latter key can stay "down" because its key up command was not sent. I'm testing a fix for it, and once I'm confident with it, I will send upload it to my fork and ping @rbreaves with a Pull request.

j4byers avatar Jun 18 '23 18:06 j4byers

Please do. And yes I also do run into stuck modifiers, I don’t think it’s quite to the level of daily on Windows but probably 1-3x every 2-3 days. I’m sure it’s dependent on what’s happening but I’ve yet to see the reproducible pattern or delve into it.

I just tap my modifier keys & move on sadly.

rbreaves avatar Jun 22 '23 04:06 rbreaves

I'm running into an issue where using a windows keyboard on windows and traversing lines using CMD (alt) + left/right arrow, if the keybind is triggered in quick succession it starts behaving really weird or failing to work until I let go and re-press the keys.

accua avatar Sep 26 '23 21:09 accua

@rbreaves I think I finally have it fixed, along with a LOT of other MacOS functionality that I've been adding over the months. I have figured out pretty well everything. I rewrote the whole CMD+Key functions, and it seems to work well now.

@accua My version doesn't seem to have that problem, though I also re-wrote the CMD+arrows to change depending on if it's in a text box.. Like Mac CMD+arrow moves to beginning/end of line ONLY if it's focused on a text box. Otherwise, like a Mac it navigates back and forward in browsers/explorer/etc.

I'll see if I can get a fork up this week, so you can take a look. I still have to do a write-up to explain all the new features—I comment my code neurotically, so you will probably understand it.

j4byers avatar Nov 07 '23 21:11 j4byers

u

This sounds great, I shift through tabs backwards a lot using the Shift key. I don't get how i can install your forked version? When I download the fork from your profile, i see no changes made to the kinto.ahk? also wouldnt it just download the original version from rbreaves upon installing?

gnagga avatar Feb 03 '24 22:02 gnagga

Sorry I haven't put the repo online yet. When I thought I had the sticky key issue solved, I was mistaken and it just happened less often.

However, after trying like 10 different methods, I think I finally solved it and have been testing my new solution for a few days now, and I haven't had a stuck key once yet, so fingers crossed.

My kinto version also has a lot more custom additions that are beyond the scope of Macos changes... (e.g. chatgpt integration, mouse gestures for the logi mx master mouse, app-specific stuff).

I have basically been continuously updating it so when I notice there is some action I would reflexively do on my Mac, and it doesn't do it on windows, I add it, lol, so it's getting quite complex.

I have one more macos-style function I'm working on (virtual desktop management), then I will push the repo this weekend (this time for sure) . I'd be happy to have some testers, especially for the stuck keys fix.

I just have to make sure that it will play nicely with the original kinto scripts and installation, then I'll get it up.

On Sat, Feb 3, 2024, 5:51 p.m. gnagga @.***> wrote:

u

This sounds great, I shift through tabs backwards a lot using the Shift key. I don't get how i can install your forked version? When I download the fork from your profile, i see no changes made to the kinto.ahk? also wouldnt it just download the original version from rbreaves upon installing?

— Reply to this email directly, view it on GitHub https://github.com/rbreaves/kinto/issues/794#issuecomment-1925476907, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIF3LGYJ55PMX3RWDAUMVLYR25PPAVCNFSM6AAAAAAWQQ6SVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGQ3TMOJQG4 . You are receiving this because you commented.Message ID: @.***>

j4byers avatar Feb 04 '24 00:02 j4byers