#include <stdio.h>\r
+\r
+#ifdef _WIN32\r
#include <conio.h>\r
+#else\r
+#include <termios.h>\r
+#include <unistd.h>\r
+#include <stdio.h>\r
+\r
+/* reads from keypress, doesn't echo */\r
+int getch(void)\r
+{\r
+ struct termios oldattr, newattr;\r
+ int ch;\r
+ tcgetattr( STDIN_FILENO, &oldattr );\r
+ newattr = oldattr;\r
+ newattr.c_lflag &= ~( ICANON | ECHO );\r
+ tcsetattr( STDIN_FILENO, TCSANOW, &newattr );\r
+ ch = getchar();\r
+ tcsetattr( STDIN_FILENO, TCSANOW, &oldattr );\r
+ return ch;\r
+}\r
+\r
+/* reads from keypress, echoes */\r
+int getche(void)\r
+{\r
+ struct termios oldattr, newattr;\r
+ int ch;\r
+ tcgetattr( STDIN_FILENO, &oldattr );\r
+ newattr = oldattr;\r
+ newattr.c_lflag &= ~( ICANON );\r
+ tcsetattr( STDIN_FILENO, TCSANOW, &newattr );\r
+ ch = getchar();\r
+ tcsetattr( STDIN_FILENO, TCSANOW, &oldattr );\r
+ return ch;\r
+}\r
+#endif\r
\r
#define ASCII_ESC 27\r
\r