Linux does have a getch() function in the curses library, but it doesn't work like it does on DOS. So this does the same thing, without the need of the curses library.
| 41 | // work like it does on DOS. So this does the same thing, without the need |
| 42 | // of the curses library. |
| 43 | int getch() |
| 44 | { |
| 45 | struct termios oldt, newt; |
| 46 | int ch; |
| 47 | |
| 48 | tcgetattr(STDIN_FILENO, &oldt); |
| 49 | newt = oldt; |
| 50 | newt.c_lflag &= ~( ICANON | ECHO ); |
| 51 | tcsetattr( STDIN_FILENO, TCSANOW, &newt ); |
| 52 | |
| 53 | ch = getchar(); |
| 54 | |
| 55 | tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); |
| 56 | return ch; |
| 57 | } |
| 58 | |
| 59 | #endif |
| 60 |