-
Notifications
You must be signed in to change notification settings - Fork 114
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
Better control over SRShortcutAction triggering policy #117
Comments
It took me a while to really understand what you detailed here. I think it's very nice and complete! I think you should clarify that the 6 options you listed would be parameters set by the library user, to customize the behavior they want on their shortcut. I have an objection regarding the 3rd section "Triggered by Modifier Key Up". I think the distinction contains vs equals that you made with policies of the first 2 sections is great, and should also be available for the 3rd section. Once the library user has decider if if they want contains or equal for their shortcut, they could also specify the up-trigger policy of "first key" vs "last key". I think it should combine:
This is how I see section 3: Triggered by Modifier Key Up
A little bit more justification for all the use-cases:
|
Did a couple of clarifications and added the missing policies you pointed out. A couple of things:
|
I was not sure what you meant with the underlining. Now you made it clearer. I think there is an issue with the approach though. In almost all policies, you can look at the currently pressed or not-pressed keys when a key triggers a up or down event, and that local context is enough. However, in the Triggered by Modifier Key Up + Last Key Up scenario, there needs to be memory that keys were at one point all down. Then when a key up event triggers, we can compare with that memory. Only once the last key up event trigger, we can say "all the modifiers of a registered shortcut were down at one point, and all these modifiers are up now, so we should trigger the shortcut. Since that's the only policy that requires a global tracking that the others don't, I would suggest implementing it later potentially. Maybe no actual user need that policy for now. For my app, and I think for @bryanforbes's app, I think First Key Up does the job. Basically I think it's nice to enumerate all possible cases to be complete, but since these sophisticated policies may require a lot of work or add new constraints to ShortcutRecorder, it would be reasonable to skip them for the time being, and focus on the small gap needed by the two actual users who are blocked to use ShortcutRecorder in their app at the moment. I'm thinking of that as a 80/20 kind of thing
Yes it is not there. I wanted to illustrate inputs ignored since it's a contain policy. |
Hi @Kentzo! Is this issue on your roadmap? I'm kind of waiting on it to be implemented for alt-tab-macos. If you don't have bandwidth to implement that use-case in the coming months, please let me know, that way I can look into another framework as a plan B. Thank you! :) |
It's definitely on my list, but I'm quite busy atm for the open source projects I maintain. If you have a commercial interest in this and would like to expedite the process, please contact me and we can arrange something. |
Added support for modifier-only key-up and key-down events when modifier flags match exactly. |
Currently the shortcut is triggered either by non-modifier key-up or key-down event and additional matching is done by checking the modifier flags. It does not handle modifier-only shortcuts.
Terminology
Shortcut Sequence: sequence of
key-down
andkey-up
events from the firstkey-down
through the lastkey-up
Non-Modifier Key: any other key than
NSEvent.ModifierFlags
Modifier Key: any of the
NSEvent.ModifierFlags
keysActive Modifier Keys: modifier keys as reported by
NSEvent.modifierFlags
Shortcut Sequence Modifier Keys: modifier keys that were pressed within Shortcut Sequence but are currently up
Required Modifier Keys: modifier keys required by the shortcut
Triggering Policies
In examples bellow
underscore
highlights modifier key events recognized by the policy.bold
highlights the key event that triggered policy recognition.highlights keys that are ignored by the policy.strikethrough
Triggered by Non-Modifier Key Down / Up
shift-a
:shift-down
-a-down
/a-up
shift-a
:shift-down
--ctrl-down
a-down
/a-up
Triggered by Modifier Key Down
ctrl-shift
:ctrl-down
-shift-down
ctrl-shift
:ctrl-down
--cmd-down
shift-down
Triggered by Modifier Key Up
cmd-ctrl-shift
:cmd-down
-ctrl-down
-shift-down
-ctrl-up
cmd-ctrl-shift
:cmd-down
-ctrl-down
-cmd-up
-shift-down
-shift-up
-ctrl-up
cmd-ctrl-shift
:cmd-down
-ctrl-down
--opt-down
shift-down
-ctrl-up
cmd-ctrl-shift
:cmd-down
-ctrl-down
-opt-down
-cmd-up
-shift-down
--opt-up
shift-up
-ctrl-up
Testimonials
@bryanforbes needs to globally handle an exact match of a modifier-only shortcut for both key down and key up.
The text was updated successfully, but these errors were encountered: