gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.31k stars 247 forks source link

[FEATURE] more keys in `event::Keys` #756

Open Redhawk18 opened 1 year ago

Redhawk18 commented 1 year ago

Is your feature request related to a problem? Please describe. I'd like to use the Alt key to show my menubar.

Describe the solution you'd like Adding more key presses to the event and the Key's enum

Describe alternatives you've considered Using different keys

gyscos commented 1 year ago

Hi, and thanks for the report!

We could add these keys to the enum, but the main issue is going to be backend support. As far as I know, there is no easy way for a terminal application to know when the Alt key was pressed by itself. It's unfortunate, but is a result of the very limiting interface between a terminal emulator and the application running inside.

In theory, other backends (like BearLibTerminal, or some javascript canvas backends) would be free of these limitations and could catch and return these events. I'm just worried that because it would be unsupported for most "regular" backends, it would be confusing for most users. Rather, I'm thinking of allowing backends to define custom events for users who know they're using this backend.

But in the general case or running inside a terminal, we just have to accept that some key events are just not available. :(

Note that if you find an event that is sent to the application by the terminal and is not currently supported, then I'm absolutely open to adding support! Especially if ncurses/crossterm/... detects it.

Redhawk18 commented 1 year ago

is there a way to directly access the backend im using? Im using crossterm, it seems like this would be a lower level feature and it would involve a lot of conditional compiling. But it feels like its worth exploring