Using a Ctrl + character to break a loop

I'm trying to develop a keyboard input function that will allow a user to continue to input data, from inside a loop, until he or she chooses to press a ctrl-key combination, say, for instance, ctrl + q. After that combination is pressed the loop should break. I'm not really sure how to get started at getting this to work. Can anyone help me with that? Thanks.

If you really want to use a Control+key sequence, you can use a crate like "crossterm" which allows raw terminal input/output.

It would be simpler however if you just read a string using the Rust standard I/O library.

Check out this example of both methods here:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.