You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When listening to keyboard events, we should be able to also capture media key code events, such as for example MediaKeyCode::Stop, but this doesn't work.
To Reproduce
Run this code:
use std::io::stdout;use std::time::Duration;use crossterm::event::{self,Event,KeyCode,KeyEvent,KeyboardEnhancementFlags,MediaKeyCode,PopKeyboardEnhancementFlags,PushKeyboardEnhancementFlags,};use crossterm::execute;use crossterm::terminal::{
disable_raw_mode, enable_raw_mode,EnterAlternateScreen,LeaveAlternateScreen,};fnmain() -> std::result::Result<(),Box<dyn std::error::Error>>{letmut stdout = stdout();execute!(stdout, EnterAlternateScreen)?;enable_raw_mode();let push_result = execute!(
stdout,
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES
| KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS));println!("PushKeyboardEnhancementFlags: {:?}", push_result);loop{// Wait for an event with a timeout of 500 millisecondsif crossterm::event::poll(Duration::from_millis(500))? {// Read the eventifletEvent::Key(KeyEvent{
code,
modifiers,
kind,
state,}) = event::read()?
{println!("modifiers: {:?}", modifiers);println!("kind: {:?}", kind);println!("state: {:?}", state);match code {KeyCode::Media(code) => match code {MediaKeyCode::Stop => {println!("Stop!")}
_ => println!("Other media key pressed: {:?}", code),},// Handle other KeyCode variants hereKeyCode::Char('q') => {println!("Exiting...");break;}
_ => println!("Other key pressed: {:?}", code),}}}}let pop_result = execute!(stdout, PopKeyboardEnhancementFlags);println!("PushKeyboardEnhancementFlags: {:?}", pop_result);execute!(stdout, LeaveAlternateScreen)?;disable_raw_mode();Ok(())}
Expected behavior
We should see the MediaKeyCode events triggering, but they do not.
OS
Linux (Ubuntu 20.04)
Terminal/Console
Standard default GNOME terminal.
The text was updated successfully, but these errors were encountered:
Describe the bug
When listening to keyboard events, we should be able to also capture media key code events, such as for example
MediaKeyCode::Stop
, but this doesn't work.To Reproduce
Run this code:
Expected behavior
We should see the MediaKeyCode events triggering, but they do not.
OS
Linux (Ubuntu 20.04)
Terminal/Console
Standard default GNOME terminal.
The text was updated successfully, but these errors were encountered: