Try these suggestions. You can get the ASCII codes by getch()
How to bind arrow keys in C?
-
24-06-2022 - |
Question
I am a beginner C coder and I want to know how the make it so the program will do this.
printf("which direction would you like to go?\n");
/*they type an arrow key*/
printf ("you went left/right/up/down\n");
I have a Mac
Solution
OTHER TIPS
Pure C (and C++ by that matter) doesn't even require your system to have a keyboard, a mouse, or a screen (from the C++ FAQ, at http://www.parashift.com/c++-faq/input-output.html).
I would recommend searching for some sort of GUI (like Qt or GTK) in order to do stuff like that. I believe it is possible for ncurses to bind those sorts of events, if a command-line interface is what you want to do.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow