charmbracelet / bubbletea

A powerful little TUI framework 🏗
MIT License
25.59k stars 741 forks source link

Kitty Keyboard Protocol #869

Open Broderick-Westrope opened 8 months ago

Broderick-Westrope commented 8 months ago

Is your feature request related to a problem? Please describe. It would be nice to see a solution to detecting key release events. Currently, for any action that requires this functionality in my Bubbletea apps I have replaced it with pressing the key to toggle which is less than ideal.

Describe the solution you'd like The ideal solution would be to have an actionType (or similar) field that determines what happened (press, release, etc). Unfortunately, this would likely break a lot of existing code, so another solution would be to add release versions of all the basic keys.

Describe alternatives you've considered I've considered cloning the Bubbletea package for projects that require it, and adding the functionality using solutions such as gohook. I am unsure of other potential solutions.

Additional context If anyone has other ideas of how this could be achieved, either on my own or how I could implement this better into the Bubbletea package, please let me know!

meowgorithm commented 8 months ago

Hi! So if you're targeting all terminals you simply cannot detect release events as terminal input handing is rather archaic.

Adding support for the Kitty keyboard protocol would add support for release events and a bunch of other nice things, but bear in mind that there are only a few terminals that support the protocol at the moment.

Maintainer's notes:

fixterms/CSI u (https://github.com/charmbracelet/bubbletea/issues/293), also proposed, does not support key release events. The Kitty keyboard is mostly backwards compatible with this protocol, but not entirely.

A large, high fidelity range of input options, including key release, are available in Windows as evidenced in https://github.com/charmbracelet/bubbletea/pull/140. We didn't merge that because of the large amount of Windows-only code and the maintenance burden that would come with it.

meowgorithm commented 4 months ago

Just a note that this is currently in development on the term-input branch.