Cross platform getch() in python
1 2 import sys, tty, termios 3 fd = sys.stdin.fileno() 4 old_settings = termios.tcgetattr(fd) 5 tty.setraw(sys.stdin.fileno()) 6 ch = sys.stdin.read(1)
For Windows, it uses msvcrt module.
1 2 import msvcrt 3 ch = msvcrt.getch()
See more details and OSX code in this recipe by Danny Yoo.