#console #terminal #press #continue #key #prompt #windows

press-btn-continue

A smalll no-dependency library to get a "Press any key to continue" console prompt

2 unstable releases

0.2.0 Jul 13, 2023
0.1.1 Jan 26, 2022
0.1.0 May 14, 2021

#1707 in Command line utilities

Download history 127/week @ 2023-12-11 94/week @ 2023-12-18 123/week @ 2023-12-25 53/week @ 2024-01-08 44/week @ 2024-01-15 47/week @ 2024-01-22 162/week @ 2024-01-29 123/week @ 2024-02-05 132/week @ 2024-02-12 129/week @ 2024-02-19 262/week @ 2024-02-26 117/week @ 2024-03-04 111/week @ 2024-03-11 97/week @ 2024-03-18 74/week @ 2024-03-25

403 downloads per month
Used in bunnyhop

MIT license

7KB
111 lines

Press any button to continue

Small crate that gives an easy access to the classic Windows "Press any key to continue" console prompt.

There is currently no way to implement this using Rust's standard library. The closest you can get is to read one character from stdin but the user has to press "ENTER" to do that so you essentially get "Press ENTER to continue..." doing like this:

println!("Press ENTER to continue...");
let buffer = &mut [0u8];
std::io::stdin().read_exact(buffer).unwrap();

This crate provides only one method called wait which progresses on any keypress.

fn main() {
    println!("Hello world!");
    press_btn_continue::wait("Press any key to continue...").unwrap();
}

Compatibility

As of now this library only compiles on Windows but I'd be happy to add support for other platforms as well later on.

Dependencies

There are no external dependencies. I try to keep this library as lightweight and transparent as possible (easy to review, and adds very little to compile times).

No runtime deps