microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.27k stars 8.27k forks source link

Add windows key support for key bindings #16909

Closed cktgh closed 6 months ago

cktgh commented 6 months ago

(While there are similar issues I suppose this is not exactly a duplicate)

Please consider adding support for the Windows modifier key in key binding settings. Right now only the other 3 modifier keys (Ctrl, Alt and Shift) is functional.

zadjii-msft commented 6 months ago

I'm pretty sure we already do support win as a modifier?

Looks like we've supported that for like, 3 years now. What exactly are you trying/?

cktgh commented 6 months ago

Sorry for being unclear, I presumed that the windows key was not supported to begin with, because key presses on the windows key are not detected when modifying key bindings on the UI: WindowsTerminal_vnB5PBO7sY

cktgh commented 6 months ago

Now that I looked into it, changing a key binding (that involves the window key) manually through editing the JSON occasionally works.

Code_7mFQeOxyd8 WindowsTerminal_DS0I6gkOuG

Here I noticed that changes to the key bindings is registered, yet it is non-functional if there is an existing binding using the same key combinations. e.g. win+t is non-functional; win+n is functional.

EDIT: I read the pull request you linked

So the list of valid combos is vanishingly small. It's all about that win+~

😢

cktgh commented 6 months ago

Terminal's distant cousin iTerm2 actually supports the equivalent of what I was trying to do pretty well 😅

To mitigate the issue I have written a script in AHKv2. Unfortunately this script doesn't work with the option "Hide Terminal in the notification area when it is minimized":

#Requires AutoHotkey v2.0

#T::toggleTerminal
!^T::launchTerminal

toggleTerminal(){
    if(ProcessExist("WindowsTerminal.exe")){
        hwnd := WinGetID("ahk_exe WindowsTerminal.exe")
        if(WinExist(hwnd)){
            WinActive(hwnd) ? WinMinimize(hwnd) : WinActivate(hwnd)
        }
    }
    else{
        launchTerminal()
    }
}

launchTerminal(){
    Run("wt -d D:\")
}

I hope this helps anyone else who have the same issue.

zadjii-msft commented 6 months ago

Yea, Win+T looks like it's not going to work in the Terminal directly, since that's a keyboard shortcut that's reserved by the OS for focusing the taskbar (at least, that's seemingly what it does on Windows 11).

Thanks for following up!

cktgh commented 6 months ago

It would be nice if we could override the key binding reservation, it can definitely be done as demonstrated by AHK, even wiithout administrator rights

I don't think anyone takes "OS reseved windows key bindings" seriously; WIN+CTRL+SHIFT+ALT+L opens Linklin in our default browser, so even the OS doesn't take it seriously 😂