Tom4nt / Mega-Soundboard

Play and manage sounds with keybinds.
MIT License
12 stars 1 forks source link

Optional Overlapping Shortcuts #37

Closed Tom4nt closed 1 year ago

Tom4nt commented 2 years ago

Currently, when a shortcut overlaps another, both are always executed. An option called Overlap Shortcuts could be added to allow this behavior to be disabled.

Example

We have the following shortcuts: Ctrl+Shif+F and Ctrl+F. Let's say they are associated with sounds 1 and 2, respectively. If we press Ctrl+Shif+F, both sound 1 and 2 will be played because Ctrl+F is contained in Ctrl+Shif+F, so both are triggered.

This is the current behavior. Equivalent of having the future Overlap Shortcuts option enabled. With Overlap Shortcuts disabled, only the longer shortcut is triggered. Meaning that, it this example, only sound 1 plays because only Ctrl+Shif+F is triggered.

Technical insight

Since shortcuts are only triggered after a key that overlaps it is released, this should be easy to implement. If a set of keys is pressed, say Ctrl+Shift+F and then a key contained in it is released, say Shift, this will only trigger Ctrl+Shift+F as long as it is the longest key chain being pressed that contains Shift. This with Overlap Shortcuts disabled.

With Overlap Shortcuts enabled, the key chain in this same scenario will trigger Shift, Ctrl+Shift, Shift+F and Ctrl+Shift+F because they are the possible intersections of Ctrl+Shift+F with Shift.

This will be implemented in a new shortcut system that will handle shortcuts and isolate all of the logic.

Notmaps-G-Spamton commented 2 years ago

would love to see this fixed

Tom4nt commented 1 year ago

Fixed in 6aeb617016a09e60612fdca46cc8445eb07dac41 by implementing "Process keybinds only on key release".