kbhit

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> #include <stdio.h> #include <termios.h> #include <unistd.h> static struct termios initial_settings, new_settings; static int peek_character = -1; int kbhit() { char ch; int nread; if(peek_character != -1) return 1; new_settings.c_cc[VMIN]=0; tcsetattr(0, TCSANOW, &new_settings); nread = read(0,&ch,1); new_settings.c_cc[VMIN]=1; tcsetattr(0, TCSANOW, &new_settings); if(nread == 1) { peek_character = ch; return 1; } return 0; } int main(void) { if(kbhit()) printf("Hello World!\n"); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines