Python Forum

Full Version: looking for code to do timed prompt on terminal
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am looking for code or a function that can do a time limited prompt at a terminal. this would usually be a one key input to end the prompt and let the calling program know the user has a specific alternate request ... or the prompt times out and assumes any user, if present, wants the default action.

the ideal function would have a means to specify the timeout period, and message to display with a way to insert the remaining time so the message updates as the time counts down to zero. these can be separate arguments.

    key = timedprompt(20,'you have %s seconds remaining to type in a letter')
    if not key:
        log('no prompt input')