Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <termios.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int main () {
  7.         struct termios termparams;
  8.         struct termios* termparams_p;
  9.         char pressed;
  10.         char* pressed_p;
  11.         pressed_p = malloc(sizeof(char));
  12.         tcgetattr(0, termparams_p);
  13.         termparams_p->c_lflag &= ~(ECHO | ICANON);
  14.         termparams_p->c_cc[VTIME] = 0;
  15.         tcsetattr(0, TCSANOW, termparams_p);
  16.         read(0, pressed_p , 1);
  17.         printf("Button pressed: %s", pressed);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement