refactor(examples): use crossterm event methods (#1792)

Crossterm 0.29 introduced methods to easily check / extract the event
type. E.g. as_key_press_event() and is_key_press(). This commit
updates the examples to use these methods instead of matching on
the event type. This makes the code cleaner and easier to read.

Also does a general cleanup of the event handling code in the examples.
This commit is contained in:
Josh McKinney
2025-05-10 10:35:12 -07:00
committed by GitHub
parent 1874b9dd55
commit 8d60e96b2b
45 changed files with 382 additions and 416 deletions

View File

@@ -30,8 +30,8 @@ fn main() -> Result<()> {
fn run(mut terminal: DefaultTerminal) -> Result<()> {
loop {
terminal.draw(render)?;
if matches!(event::read()?, event::Event::Key(_)) {
break Ok(());
if event::read()?.is_key_press() {
return Ok(());
}
}
}