Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input event loop in a console application

I'm trying to make a little console application that is able to deal with keystrokes as events. What I need is mostly the ability to get the keystrokes and be able to do something with them without dealing with the typical stdin reading functions.

I tried to check the code of programs like mplayer, which implement this (for stopping the play, for example), but I can't get to the core of this with such a big code base.

Thanks

like image 932
alvatar Avatar asked Mar 07 '26 23:03

alvatar


1 Answers

You could use the ncurses family of functions 'getch' as shown in the link, here's another link that will be of help to you, by the way, it should be pointed out, ncurses is platform portable so you should be pretty ok with it if you decide to re-target to another platform which is a big plus...

like image 153
t0mm13b Avatar answered Mar 09 '26 14:03

t0mm13b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!