Skip to content

Instantly share code, notes, and snippets.

@antoni
Created September 17, 2015 11:21
Show Gist options
  • Select an option

  • Save antoni/78d0c239a6703f86a37f to your computer and use it in GitHub Desktop.

Select an option

Save antoni/78d0c239a6703f86a37f to your computer and use it in GitHub Desktop.
Hide & show keystrokes in a Linux terminal
#include <termios.h>
void hide_keystrokes() {
struct termios tty;
tcgetattr(STDIN_FILENO, &tty);
tty.c_lflag &= ~ECHO;
tcsetattr(STDIN_FILENO, TCSANOW, &tty);
}
void show_keystrokes() {
struct termios tty;
tcgetattr(STDIN_FILENO, &tty);
tty.c_lflag |= ECHO;
tcsetattr(STDIN_FILENO, TCSANOW, &tty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment