Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't print char when using getch() ncurses

Tags:

input

ncurses

I need to get a char with ncurses, but when I get the char, I don't want it printed to the screen. Is there a way to do this?

like image 295
user1753491 Avatar asked Jul 09 '26 14:07

user1753491


1 Answers

Assuming you're using C, you can use noecho();.

The following is a relevant excerpt from the manual pages.

The echo and noecho routines control whether characters typed by the user are echoed by getch as they are typed. Echoing by the tty driver is always disabled, but initially getch is in echo mode, so characters typed are echoed. Authors of most interactive programs prefer to do their own echoing in a controlled area of the screen, or not to echo at all, so they disable echoing by calling noecho.

like image 196
Chrisuu Avatar answered Jul 14 '26 15:07

Chrisuu