In my calculator application (https://github.com/fjl/gio-demos/tree/master/giocalc), I would like to handle the "minus" key. However, since the minus sign is used in the key.Set syntax, it cannot be matched by Set.Contains, and events for this key are not delivered.
I think the minus key could be supported with this syntax:
op := key.InputOp{
Set: "(Shift)-(Alt)-[-]",
}
Thanks for pointing this out! I think these functions need to be taught some kind of escaping syntax to allow that, or maybe we simply need to check whether the final character is "-" and handle that differently. ~eliasnaur, do you have a preference on the approach?
Alternative idea: use another data structure for key sets. I'm suggesting this also because there are a few other problems with the current key.Set system being based on a string syntax:
- it's not intuitive to work with when the declared key set is dynamic
- the code to match keys must parse the set syntax every time
- it does not support declaring listeners for modifier-only events (AFAIK)
I'm happy to work out something better, but it'll take a while.
Several Gio users have expressed their dislike over the data structure. I'm happy to accept proposals for a replacement, thanks!
+1 to ~fjl's idea, because with existing syntax square braces and commas also couldn't be used.
While we're here, it'd be nice to be able to specify a set matching all keys, without having to specify every possible key. This comes up in modals, as well as in widget.Editor, which mostly uses edit events, causing most key presses to bubble up.