<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def wait_key(keys=None):
    ''' Waits for a keypress at the console and returns it.
        "Where's the any key?"

        Arguments:
            keys - if passed, wait for this specific key, e.g. ESC.
                   may be a tuple.
        Returns:
            char or ESC - depending on key hit.
            None - immediately under i/o redirection, not an interactive tty.
    '''
    if is_a_tty():
        if keys:
            if not isinstance(keys, tuple):
                keys = (keys,)
            while True:
                key = _getch()
                if key in keys:
                    return key
        else:
            return _getch()