crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.27k stars 279 forks source link

Capture additional keys (Media keys, caps lock, etc.) #895

Open SammyWhamy opened 5 months ago

SammyWhamy commented 5 months ago

Is your feature request related to a problem? Please describe. I would like to be able to control a media player in the terminal using my hardware media keys, but these are not captured by crossterm.

Describe the solution you'd like I'd like the read/poll functions to also report keys such as the hardware multimedia keys, along with keys like num lock, caps lock, etc. It would also be nice if keys like shift and ctrl could be reported separately, instead of only as modifiers.

Additional context Windows 11, cmd/powershell, Windows Terminal I have played around a bit with the crossterm_winapi crate, and I was able to fairly easy get readings for these keys. Using the following

let handle = crossterm_winapi::Handle::current_in_handle()?;
let console = crossterm_winapi::Console::from(handle);
let key = console.read_single_input_event()?;

Seeing as how easy this was to do, I feel like i might be overlooking something in crossterm, but I can't find any way to get readings for these keys.