Get keyboard input events


#1

As my first project in Rust I’m trying to write a Chip8 emulator (which is the first emulator I have ever written so far). What I’m trying to accomplish is to read the keyboard without blocking the main loop.

So the first thought I got was about events. I search for a while and found input, which it doesn’t seem to work since it doesn’t compile and I have some problems as well with the linker. I found glutin as well, but it requires to build the window and I would like to use the terminal to “screen”.

Are there any other options? Thanks!


#2

Since you’re going to drawing to the console as well as handling key events, consider using a library for text user interfaces (TUIs).

curses is a very popular C library that does this, and ncurses is a Rust wrapper for it. Also, a search for TUI on crates.io turns up a handful of other Rust libraries for making TUIs, which might provide a more Rust-y experience than the curses wrapper.


#3

A bunch of emulators uses a crate I have made https://github.com/emoon/rust_minifb which may be a starting point.

Now this may not fit exactly what you want if you want to display in the terminal but I figured that it may still be interesting for you.