Questions tagged [getch]

Questions relating to the use of the DOS getch() function

getch() is defined in <conio.h>, a header file used mostly by MS-DOS compilers to provide console input/output.

This function is provided on Microsoft platforms, but is not in the C standard library, nor in POSIX.

It is similar to the standard library getchar(), but disables terminal echo of the character that is returned.

299 questions
8
votes
3 answers

How to have password echoed as asterisks

I'm trying make a login window where a user is prompted to enter their Username and Password, although when the password is entered I am looking for asterisks to be printed, like common password entry (i.e. - Sekr3t is echo'd as: * * * * *…
zk-Jack
  • 83
  • 1
  • 1
  • 9
7
votes
1 answer

python tty.setraw Ctrl + C doesn't work (getch)

This is my code. def getch(): fd = sys.stdin.fileno() old_Settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) sys.stdin.flush() except KeyboardInterrupt: print ("[Error] Abnormal program…
SoosanShin
  • 85
  • 4
7
votes
2 answers

C++ getch() in perl?

In c++, there is a functio, getch(), which returns the variable of the key you pressed - like enter would be 13. How could I do this in perl?
Karandeep Singh
  • 1,223
  • 5
  • 22
  • 34
7
votes
3 answers

How to use getch() without waiting for input?

for (;;) { cout << "You are playing for:" << playtime << "seconds." << endl; cout << "You have " << bytes << " bytes." << endl; cout << "You are compiling " << bps << " bytes per second." << endl; cout << "Press a to buy assembler…
Fairlight
  • 79
  • 1
  • 4
7
votes
1 answer

What does getch() really get? Scan codes?

#include int main (void) { for (;;) { unsigned char ch = getch(); printf ("0x%02X\n", ch); } } I want to get the scan code. Here is the description from Wikipedia: Reads a character directly from the…
Kevin Dong
  • 5,001
  • 9
  • 29
  • 62
6
votes
5 answers

How to detect key presses on console?

I'm writing a roguelike in Scala. I need to be able to see when the user presses an arrow key for example. All of the solutions I have found require the player to press enter. Is there any way to detect keypresses in a console app in a similar…
Serentty
  • 263
  • 3
  • 8
6
votes
4 answers

How to read in a single keyboard character (like getch)?

In C, I could use getch() for getting an input without having the user to press enter. e.g. #include int main() { char c; c = getch(); return 0; } What function can do the same in C#? (without pressing enter).
alextikh
  • 119
  • 1
  • 9
6
votes
1 answer

How to use kbhit and getch (C programming)

I'm trying to create a function that will printf a certain string if the user presses any button on the keyboard EXCEPT for capital P, if the user presses P then it will break the loop. However I don't think I'm using _kbhit and _getch properly. I…
Pardon_me
  • 715
  • 2
  • 8
  • 20
5
votes
2 answers

Linux equivalent for conio.h getch()

Previously I use c++/c compilers on windows which support the #include header file but on Linux where I have gcc (Debian 4.9.2-10) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software... I want a function which…
user5514593
5
votes
1 answer

Python/curses user input while updating screen

I'm currently coding an app U.I with python/curses and I was wondering if it is possible to ask the user to press keys (cbreak mode) to hide or show some panels or windows while the U.I is continuously updating. I read the official python docs about…
MCO System
  • 404
  • 5
  • 12
5
votes
2 answers

Clear buffer for keyboard

In function boo() I press a key, then the function doSthTimeConsuming() is called. Now I am pressing keys during doSthTimeConsuming(). Problem is that keys are buffered and in the next iteration boo() will already have an input. Could I clear or…
Rob
  • 708
  • 8
  • 27
4
votes
1 answer

how to raise event getche() from process.Popen() - does not monitor stdin

I am launching a binary in windows using: process = subprocess.Popen(cmd, stderr = subprocess.PIPE, stdin = subprocess.PIPE, stdout = ch.input) ch.input comes from: ch = InputStreamChunker('\n') ch.daemon = True ch.start() which was a cool non…
4
votes
0 answers

How to get single character input in Jupyter?

In Jupyter, using python 3, I am trying to run a cell that is supposed to ask for a single character input in a for loop and store the answer in a list. I wanted to avoid the use of input() to avoid having to press enter everytime. Working in…
msfrn
  • 57
  • 3
4
votes
1 answer

getch() doesn't work properly in the latest version of Microsoft Visual Studio 2017 C

I spent the last couple of weeks working on an aplication which basicly relies on the getch() function, then I recently decided to update visual studio only to find out that my program is completly broken and doesn't work anymore. Heres a simple…
4
votes
5 answers

Help with getch() function

I want to use the getch function to get a character... So the user can enter only Y OR N Character.. but the while loop is not working... I need help! Thanks #include main(){ char yn = 0; printf("\n\t\t Save changes? Y or N […
newbie
  • 14,582
  • 31
  • 104
  • 146
1
2
3
19 20