# File lib/rbreadline.rb, line 4506
  def rl_read_key()
    @rl_key_sequence_length+=1

    if (@rl_pending_input!=0)
      c = @rl_pending_input
      rl_clear_pending_input()
    else
      # If the user has an event function, then call it periodically.
      if (@rl_event_hook)
        while (@rl_event_hook && (c=rl_get_char()).nil?)

          send(@rl_event_hook)
          if (@rl_done)     # XXX - experimental
            return ("\n")
          end
          if (rl_gather_tyi() < 0)   # XXX - EIO
            @rl_done = true
            return ("\n")
          end
        end

      else

        if (c=rl_get_char()).nil?
          c = send(@rl_getc_function,@rl_instream)
        end
      end
    end

    return (c)
  end