all AI news
How to get the Ctrl + C event in rust? 🔭🔮
Jan. 23, 2024, 7:23 p.m. | Stacy Roll
DEV Community dev.to
If you want to obtain the Ctrl + C event before the process ends in your terminal, in this article I am going to show you how to do it!
Cargo.toml
[dependencies]
k_board = { version = "1.2.4", features = ["ctrl_lower_letter"] }
main.rs
use k_board::{keyboard::Keyboard, keys::Keys};
fn main() {
for key in Keyboard::new() {
match key {
Keys::Ctrl('c') => {
println!("Yeah, you press Ctrl + C and the console doest ends!!");
break;
},
_ => (),
}
}
}
See …
article beginners dependencies development event features keyboard keys process rust show terminal tutorial
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Lead Developer (AI)
@ Cere Network | San Francisco, US
Research Engineer
@ Allora Labs | Remote
Ecosystem Manager
@ Allora Labs | Remote
Founding AI Engineer, Agents
@ Occam AI | New York
AI Engineer Intern, Agents
@ Occam AI | US
AI Research Scientist
@ Vara | Berlin, Germany and Remote