DEV Community

Stacy Roll
Stacy Roll

Posted on

2 1 1 1 1

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)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More