I'm trying to call a function when a user presses a key, somewhat like sending a signal with Ctrl-C. The idea is to be doing something, say in a while loop, and actively listen for, say, the 'f' key being pressed. When it is pressed, the program will stop performing the loop and do something else because the 'f' key was pressed.
Is there a way to customize the signal mapping? I didn't have much luck with this. There also seemed to be 1 or 2 available signals for customization, but I need 3.
If I use getchar(), the user needs to press the 'f' key AND THEN press the enter key. I would like for them to just press the 'f' key and not have to press the enter key.
It is very similar to using unix's more
program where the user can just press the space bar to go through pages.
Any help is greatly appreciated!