Get single character from standard input on Windows and Unix. Copied from http://code.activestate.com/recipes/134892/