Console Press Any Key Message (Windows Only)

jcao219 0 Tallied Votes 217 Views Share

Most people would do something like this: input("Press any key to continue") #or raw_input This way, if the user presses a key other than the Enter (return) key, then the program will still continue.

It looks something like this:
http://i42.tinypic.com/2yvp9hj.png

import msvcrt

def any_key_message(message):
    for char in message:
        char = char.encode('utf8')
        msvcrt.putch(char)
    msvcrt.getch()
    msvcrt.putch(b"\n")

any_key_message("Press any key to continue...")
any_key_message("Press any key to exit...")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.