Anze/KeyCluCask

[feature request] Manually register shortcuts

Closed this issue · 15 comments

Ability to register custom keybindings manually, such as keybindings that i want to remember (or need a reminder of).

My use case:
I have plenty of different apps where i use keyboard shortkeys, but since there are so many of them i sometimes forget those. For example, i have manually configured keybindings for terminal, for my vim code editor, for window management (using Magnet app) etc etc. So i would love to have a place where i can add my keybindings to the config and see them by invoking a help pop-up modal same way as apps like KeyCue does.

Would love to see this too for similar reasons. Another use case is adding important but undiscoverable shortcuts I find myself looking up

Just passing by to say I'd also love to see this added. In fact, that's what I was searching for when I ran across this app to begin with. I was hoping to find an application where I could easily write down shortcuts for all my applications and have them easily accessible to refer to. I had run across a different app (don't remember the name) that lives in the menu bar which acts as a sort of shortcut "cheat sheet" but that app was discontinued, so this app was what I ended up going with, and I'm glad I did. I do have 2 suggestions for this feature: I'd really like an easy way to record shortcuts including modification keys, whether that be a button to click to add a ⌥ icon, for example, or being able to record them by simply pressing the buttons. Second, it would be great if I could record shortcuts one button at a time to avoid triggering them, so if I wanted to add ⌘ + Shift ⇧ + 2, that would trigger a shortcut in doing so, so it would be nice if I could press ⌘, then Shift, then 2. This is an awesome app as it is and I'm super happy you're looking into developing this feature!

agree on the above, but i suggest implementing it in a text config file. This is a little less "UI friendly", but a lot more useful for backups/storing under your dotfiles etc. And the file format does not need to be complicated, a lot of other projects doing the same. Simple example, Alacritty here

Anze commented

While I agree that dot files would be "less UI friendly" and easier to implement, still it would be not convenient for users who are not terminal friendly. Also it would not be that easy to share (import/export) your config with others as I was planning.

can it be both @Anze ? the config is stored in dot file but UI parses it and allows one to edit/add/delete entries. And the changes are simply saved back to the dot file?

Anze commented

Technically, it is possible, but it would be complex for inexperienced users and would require some knowledge to set shortcuts. Let me explain the issue.

I'm planning to have the next format for the file, so it would be really obvious what is what.

{
    "com.googlecode.iterm2":{
        "iTerm Edits":[
            {
                "title":"Copy string",
                "modifiers":786432,
                "keyCode":8
            },
            {
                "title":"Paste string",
                "modifiers":786432,
                "keyCode":35
            }
        ],
        "iTerm Views":[
            {
                "title":"Show/hide window",
                "modifiers":786432,
                "keyCode":13
            }
        ]
    },
    "com.apple.TextEdit":{
        "Things":[
            {
                "title":"Do something with text",
                "modifiers":1835008,
                "keyCode":33
            }
        ]
    }
}

It can be simplified to be more compact and more obscure.

{
    "com.googlecode.iterm2": {
        "iTerm Edits":[
            ["Copy string", 786432, 8],
            ["Paste string", 786432, 35]
        ],
        "iTerm Views":[
            ["Show/hide window", 786432, 13]
        ]
    },
    "com.apple.TextEdit":{
        "Things":[
            ["Do the thing with text", 1835008, 33]
        ]
    }
}

While it is possible to make modifiers parseable, like control + command, making keyCode user-friendly is difficult due to the many different keyboard layouts and languages. You would need to know exactly which keyCode to use, as it represents the physical key on the keyboard that should be pressed, regardless of the language or layout.

For example, the "-/_" (minus/underscore) key (located left of "plus" and "delete") in the US looks like "? ß" (question mark/ß) in Germany. Both of them have keyCode = 27, which could lead to issues when presenting shortcuts. The shortcut might suggest pressing one key but actually expect a completely different one because the "-" key with a German keyboard layout has keyCode = 44 and a different location.

You can see that Alacritty also has the same issue. They tried to simplify it with literals like LBracket. However, this doesn't work with the German layout as there is no such key (without modifiers) to be pressed. To type [, you would need to press the option + 5 combination.

This can be misleading and unclear. I've been trying to avoid this by managing shortcuts through the UI, which mitigates this issue.

Still, I'm not sure if making it in a dot file is a good idea when implementing it through the UI would not have such complexity. It might be good to use only as a backup. I have import/export functionality in mind, as it was intended for backup and/or sharing with others who need "missing hotkeys in apps" that are not available in the menu shortcuts.

hmmm, i see the challenge... i was not that familiar of how the key modifiers, key codes and various keyboard layout may play into the feature.
if adding this only through the UI, did you think of manually registering keybindings by pressing them? that my questions is, how would the UI differentiate between the keyboard layouts when - is pressed for example? 🤔

regardless, i believe export/import feature is crucial, since it really defines whether or not users can rely on using the app past "one setup" (imagine swapping a laptop or doing a full wipe-out etc).

Anze commented

The thing is, when a user presses a key, getting the keyCode happens naturally, there's no need of special effort to find the exact number. It's just a simpler way to enter the number 27 for the - key.

Absolutely, I understand the importance of backup functionality. It will be available, as I mentioned, and can also be utilized for registering new shortcuts, thought it may not be as convenient as initially expected.

as long as it's a readable format for the text editor and maybe a few lines of docs - that is totally fine given the limitations mentioned above :)
thanks for working on those 🙌

Anze commented

Hey guys, after some time, the feature is now ready for use and could benefit from some thorough testing.

Here are the details of the new section, My Shortcuts:

  • You can now add, update, or delete custom shortcuts, both globally and per app.
  • Shortcuts can be registered in two ways: the usual method (press the shortcut, such as +C), or separately (press , then , then C, with the non-modifier key being the last to press), please note that registering workflows may not be flawless.
  • When clicked or tapped, all shortcuts are sent as user input, respecting the current keyboard layout.
  • Custom shortcuts always appear in the last column for presentation.
  • Custom shortcut keys are displayed according to the current keyboard layout, but you can also choose to show them in the default English keyboard layout.
  • Be aware of potential import issues on macOS 11/12.
  • Additionally, there may be issues when registering the FN key in macOS 11/12.

Feel free to assist with testing and let me know if you encounter any issues. Thanks!

great, thank for working on that, @Anze.
i added a custom global shortcut, exported it as json, removed all registered items and tried importing json file which did not work 🤔

Anze commented

Thank you for checking. I'm working on enhancing the import/export functionality.

Anze commented

Apologies for the log wait, the feature is now stable.

Greetings! For the record, it would be amazing if the custom shortcuts workflow supported chord hotkeys. For example, in VSCode, one hotkey is "cmd+; cmd+l" in sequence. I can't find a way to record it in the latest version.

Anze commented

Hi gsteph,
Thanks for requesting new feature. Would be nice of you if you would post it as new feature request.
To keep issues list clear i'm closing old topics by the time after collecting feedback.