summaryrefslogtreecommitdiff
path: root/conio.c
blob: 9b87cc91c6f6b8b2181c78040373a9233f8e1f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "./conio.h"
#include <termios.h>
#include <unistd.h> 
#include <stdio.h> 
int getch(void) {
	struct termios oldattr, newattr;
	int ch;
	tcgetattr(STDIN_FILENO, &oldattr);
	newattr = oldattr;
	newattr.c_lflag &= ~(ICANON | ECHO);
	tcsetattr(STDIN_FILENO, TCSANOW, &newattr);
	ch = getchar();
	tcsetattr(STDIN_FILENO, TCSANOW, &oldattr);
	return ch;
}