DEV Community

Stacy Roll
Stacy Roll

Posted on

How to get Ctrl + S, Ctrl + C in my rust app

If you are on a GNU/Linux operating system, regardless of its distribution, and you are also developing a Rust-based application that requires handling user keyboard input in raw mode (without the need to press Enter), then this article can help you address that:

We add k_board to the project.

cargo add k_board

We implement the logic:

use k_board::{Keyboard, Keys}; fn main() { for key in Keyboard::new() { match key { Keys::Ctrl('s') => //paste, Keys::Ctrl('c') => //copy, Keys::Enter => break, _ => {} } } } 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)