I am trying to create a version of pong for the MacOS terminal. However, I cannot seem to get single key input (my version of saying detecting which key is pressed at certain times.). I have tried everything, (even using the getch()
function used in the depreciated library conio.h
. I am looking to use it in a function like this:
void detect_w()
{
int ascii_key_pressed_code = <some function to get pressed keys>;
if (ascii_key_pressed_code == 0xa9)
{
// the ascii code for "A" triggered.
// do something...
}
// ....
}
For anyone who thinks "just use cin
", I want unbuffered input.