Home python GETCH Analogue in Python

GETCH Analogue in Python

Author

Date

Category

How to organize a function similar to getch () in C++? Or maybe what libraries are there? It is necessary that the program expects input one of any character.


Answer 1, Authority 100%

You can arrange something like this:

#! / usr / bin / env python3
# CursesExample1
# -------------------------------
# Curses Programming Sample 1
# -------------------------------
Import Curses.
Myscreen = Curses.initscr ()
myscreen.border (0)
MyScreen.Addstr (12, 25, "See Curses, See Curses Run!")
MyScreen.Refresh ()
MyScreen.Getch ()
curses.endwin ()

Details You can see here .

Update:

And if you have Windows, then everything is easier:

import msvcrt
While True:
  PRESSEDKEY = MSVCRT.GETCH ()
  if pressedKey == 'Q':
    Print "Q Was Prased"
  ELIF PRESSEDKEY == 'X':
    sys.exit ()
  ELSE:
    Print "KEY PRESSED:" + STR (PRESSEDKEY)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions