Created
September 17, 2015 11:21
-
-
Save antoni/78d0c239a6703f86a37f to your computer and use it in GitHub Desktop.
Hide & show keystrokes in a Linux terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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