Josh McKinney 8d60e96b2b
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.
2025-05-10 10:35:12 -07:00
..
2024-12-05 14:12:40 -08:00

Input Form example

This example demonstrates how to handle input across several form fields (2 strings and an number). It uses an enum to track the focused field, and sends keyboard events to one which is current.

Run this example with:

cargo run -p input-form

This example does not handle things like cursor movement within the line (just keys and backspace). Most apps would benefit from using the following crates for text input rather than directly using strings:

Some more ideas for handling focus can be found in: