rbreaves / kinto

Mac-style shortcut keys for Linux & Windows.
http://kinto.sh
GNU General Public License v2.0
4.49k stars 215 forks source link

Delete button in Windows Explorer not working #787

Open andyd0 opened 1 year ago

andyd0 commented 1 year ago

I updated Kinto recently and forgot that it overrides my config file. Anyone able to help with getting the delete button working again?

Update - I guess in general keys in windows explorer is acting weird - like pressing enter doesn't open the file ... it tries to rename

RedBearAK commented 1 year ago

@andyd0

✋🏽 Hi, this is my fault. Although I did this on purpose, and I'll explain. These are due to the "Finder Mods".

Disclaimer: I am not the dev, just a contributor of this particular part of the config.

Since Kinto's purpose in general is to mimic the keyboard behavior in macOS applications, for people who like how macOS works, I implemented some shortcut overrides for Windows Explorer to mimic Finder behavior. I've done the same thing for several different common Linux file managers (or as they are often called in Linux, file browsers).

The Enter key in the Finder has always been used for renaming, which a lot of Mac users like me got used to using over the much more awkward F2 shortcut that Linux and Windows uses. The F2 shortcut is often a real pain on laptops especially, where you need to go find and press the Fn key before F2, since there are typically special hardware functions on the F-keys row on laptops. Mine has a hardware function to turn Wi-Fi off on the F2 key. So in Windows users tend to use the much slower right-click menu to rename things in Explorer. I find this a huge pain ever since I got used to how it works in the Finder. Enter-rename-Enter, done. It's super fast.

To actually open files or run applications (via the keyboard) in the Finder, you use the same shortcut as you use to "drill down" into (or "open") folders in the Finder: Cmd+Down (arrow). The opposite of going "up" to the parent folder with Cmd+Up. I find it quite logical to think of it this way.

Delete (and Backspace) are blocked from deleting files immediately, in favor of the Cmd+Backspace (aka, the bigger Delete key on an Apple keyboard) shortcut used in the Finder. Because that's how all these keys work in the Finder.

How to disable the Finder Mods

If you never got used to using these keyboard shortcuts in the Finder on macOS, and you really dislike them, you can disable them pretty easily. Just open your kinto.ahk config file and search for "finder", you'll see this line just below it:

#IfWinActive ahk_class CabinetWClass ahk_exe explorer.exe

If you change the application name to something that won't match, the whole set of "Finder Mods" should stop working as soon as you close and restart Kinto (you can restart Kinto without logging out by double-clicking on the kinto-start.vbs file in the config folder).

Example:

#IfWinActive ahk_class CabinetWClass ahk_exe NOTexplorer.exe

Or, you could just comment out the particular shortcuts you can't get used to, such as the lines that block the Delete key and produce an error beep (mimicking the Finder as closely as possible):

    $Delete::           ; Delete (without Cmd): Block Delete key with error beep, unless inside text input field
    ControlGetFocus, fc, A
    If fc contains Edit,Search,Notify,Windows.UI.Core.CoreWindow1
        Send {Delete}
    Else SoundBeep, 600, 300
    Return

But, I think the Finder Mods make keyboard navigation, tab navigation (now that there are tabs again in Windows Explorer), and renaming files/folders much faster and easier if you happen to be used to how it works in the real Finder, or if you're willing to adjust to it. So I do hope you'll give it a chance before completely disabling it.

There are supposed to be exceptions in the Finder Mods for all known text fields in Explorer, so that the blocking of keys like Enter, Backspace and Delete doesn't affect the location bar or search field (or sidebar) where you would actually need them to work. And obviously, all those keys should work while you're actually renaming something. Do let me know if there is a problem in that way.

Otherwise it seems to be operating as intended.

There is a minor update that hasn't yet been applied to the master branch. I found that old-style Control Panels have an additional text area that needs to be excluded from blocking the Enter/Delete/Backspace keys:

https://github.com/rbreaves/kinto/pull/769/files

Oh, I forgot the tab navigation update hasn't been merged yet:

https://github.com/rbreaves/kinto/pull/768/files

Let me know if you have any trouble disabling whatever you want to disable.

RedBearAK commented 1 year ago

I should mention that the Finder Mods do a number of things that don't interfere with existing shortcuts, such as remapping Cmd+I to Alt+Enter to access the Properties dialog, and Cmd+1/2/3/4 to change the view mode, as well as the Cmd+arrow navigation shortcuts and Cmd+Braces to navigate the history (and Cmd+Shift+Braces for tab navigation if you apply the two new lines from PR #768, seen below). So if you disable the whole thing you'll be missing out on all that.

#IfWinActive ahk_class CabinetWClass ahk_exe explorer.exe
    ^+[::Send ^+{Tab}           ; Tab nav: Go to prior tab (left)
    ^+]::Send ^{Tab}            ; Tab nav: Go to next tab (right)
andyd0 commented 1 year ago

Ok thanks for the explanation. I guess I'm not used to Finder as much on macos so I was a little confused. I'll see how I'll feel about it for now and follow up if anything.

Thanks! Sorry for the delayed response - I was just reminded about this while in Explorer just now hah

leftbones commented 1 year ago

I know I'd definitely appreciate being able to use Delete in WIndows Explorer. I would just use Cmd + Backspace, except for whatever reason when I do that, it highlights EVERYTHING in the folder and then does delete. Muscle memory has led to me accidentally deleting my entire desktop multiple times.

RedBearAK commented 1 year ago

I know I'd definitely appreciate being able to use Delete in WIndows Explorer. I would just use Cmd + Backspace, except for whatever reason when I do that, it highlights EVERYTHING in the folder and then does delete. Muscle memory has led to me accidentally deleting my entire desktop multiple times.

@leftbones

I've never seen that happen in testing. Does it happen in any folder, or just the Desktop folder?

Are you on an Apple keyboard, or a Windows/PC keyboard?

RedBearAK commented 1 year ago

@leftbones

I was able to replicate your "select everything" issue, but only on the actual desktop, not in any Explorer windows.

This appears to be an issue with some wordwise shortcuts that have existed since before my Finder Mods. Ctrl+Backspace while on the desktop is sending Shift+Home+Delete, as if you're trying to do wordwise editing.

#IfWinNotActive ahk_group remotes
    ; wordwise support
    ^Up::Send ^{Home}
    ^+Up::Send ^+{Home}
    ^Down::Send ^{End}
    ^+Down::Send ^+{End}

    $^Backspace::Send +{Home}{Delete}

    !Backspace::Send ^{Backspace}
    !Left::Send ^{Left}
    !+Left::Send ^+{Left}
    !Right::Send ^{Right}
    !+Right::Send ^+{Right}
    $^Left::Send {Home}
    $^+Left::Send +{Home}
    $^Right::Send {End}
    $^+Right::Send +{End}
#If

I am looking into how to add the desktop to the Finder Mods, since the desktop has a different ahk_class from the normal Explorer windows. Seems the Finder Mods have never actually been active on the desktop itself.

Note that you can use both Cmd+Backspace and Cmd+Delete in Explorer windows. It is only Delete and Backspace without the Cmd key that are blocked from performing an action (unless you are in one of the "text editing" areas of the window).

RedBearAK commented 1 year ago

@leftbones

Get back to me if you can, if this solves your issue with the desktop. Replace the whole "Finder Mods" section in your kinto.ahk file with this:

; #########################################################################
; #############   START OF FINDER MODS FOR FILE MANAGERS   ################
; #########################################################################
; Finder Mods for Windows File Explorer (explore.exe)
#If WinActive("ahk_class CabinetWClass ahk_exe explorer.exe") or WinActive("ahk_class Progman ahk_exe explorer.exe")
    ^+[::Send ^+{Tab}           ; Tab nav: Go to prior tab (left)
    ^+]::Send ^{Tab}            ; Tab nav: Go to next tab (right)
    ^i::Send !{Enter}           ; Cmd+i: Get Info / Properties
    ^r::Send {F5}               ; Cmd+R: Refresh view (Not actually a Finder shortcut? But works in Linux file browsers too.)
    ^1::Send ^+2                ; Cmd+1: View as Icons
    ^2::Send ^+6                ; Cmd+2: View as List (Detailed)
    ^3::Send ^+5                ; Cmd+3: View as List (Compact)
    ^4::Send ^+1                ; Cmd+4: View as Gallery
    ^Up::Send !{Up}             ; Cmd+Up: Up to parent folder
    ^Left::Send !{Left}         ; Cmd+Left: Go to prior location in history
    ^Right::Send !{Right}       ; Cmd+Right: Go to next location in history
    ^Down::                     ; Cmd-Down: Navigate into the selected directory
    For window in ComObjCreate("Shell.Application").Windows
        If WinActive() = window.hwnd
            For item in window.document.SelectedItems {
                window.Navigate(item.Path)
                Return
            }   
    Return
    ^[::Send !{Left}            ; Cmd+Left_Brace: Go to prior location in history
    ^]::Send !{Right}           ; Cmd+Right_Brace: Go to next location in history
    ^+o::Send ^{Enter}          ; Cmd+Shift+o: Open in new window (tabs not available)
    ^Delete::Send {Delete}      ; Cmd+Delete: Delete / Send to Trash
    ; ^BackSpace::Send {Delete}   ; Cmd+Delete: Delete / Send to Trash
    $^BackSpace::                ; Backspace (without Cmd): Block Backspace key with error beep, unless inside text input field
    ControlGetFocus, fc, A
    If fc contains Edit,Search,Notify,Windows.UI.Core.CoreWindow1
        Send +{Home}{Delete}
    Else Send {Delete}
    Return
    ^d::return,                 ; Block the unusual Explorer "delete" shortcut of Ctrl+D, used for "bookmark" elsewhere
    $Enter::                    ; Use Enter key to rename (F2), unless focus is inside a text input field. 
    ControlGetFocus, fc, A
    If fc contains Edit,Search,Notify,Windows.UI.Core.CoreWindow1,SysTreeView321
        Send {Enter}
    Else Send {F2}
    Return
    $BackSpace::                ; Backspace (without Cmd): Block Backspace key with error beep, unless inside text input field
    ControlGetFocus, fc, A
    If fc contains Edit,Search,Notify,Windows.UI.Core.CoreWindow1
        Send {BackSpace}
    Else SoundBeep, 600, 300
    Return
    $Delete::                   ; Delete (without Cmd): Block Delete key with error beep, unless inside text input field
    ControlGetFocus, fc, A
    If fc contains Edit,Search,Notify,Windows.UI.Core.CoreWindow1
        Send {Delete}
    ; Else SoundBeep, 600, 300
    Else Return,
    Return
#IfWinActive
; #########################################################################
; ##############   END OF FINDER MODS FOR FILE MANAGERS   #################
; #########################################################################

This should A) enable the Finder Mods shortcuts on the desktop, and also B) block the improper "wordwise" shortcut action from selecting all the items on the desktop, while C) retaining the ability to use the "wordwise" shortcut while renaming files on the desktop.

rbreaves commented 1 year ago

This appears to be an issue with some wordwise shortcuts that have existed since before my Finder Mods. Ctrl+Backspace while on the desktop is sending Shift+Home+Delete, as if you're trying to do wordwise editing.

Oh god.. that is horrible.. yea I will need to test this PR & get it merged. Thanks @RedBearAK I know I have been absent for quite some time.. not sure it will get much better till after tax time... but yea 😅, life keeping me busy.