def find_hotkey(text, attrs, hotkey='hotkey'):
    """
    Given an urwid (text, attr) tuple (as returned by, e.g.
    :meth:`Text.get_text`), returns the first character of the text matching
    the *hotkey* attribute, or ``None`` if no character matches.
    """
    ix = 0
    for attr, rl in attrs:
        if attr == hotkey:
            return text[ix]
        ix += rl
    return None