       candidates = candidates.filter (name) ->
         name[...length].toLowerCase() == possibleName.toLowerCase()
       return  if candidates.length == 0
-      @tabCompleteIndex = 0
+      if options.reverse
+        @tabCompleteIndex = candidates.length - 1
+      else
+        @tabCompleteIndex = 0
       @tabCompleteNames = candidates
       @tabCompletePrefix = rest
       @tabCompleteCursorIndex = cursorIndex

    delete @chatHistoryIndex
    $this.val('')

  tabComplete: ($input) =>
    cursorIndex = $input.prop('selectionStart')
    text = $input.val()
    if @tabCompleteNames.length > 0 && @tabCompleteCursorIndex == cursorIndex
      @tabCompleteIndex = (@tabCompleteIndex + 1) % @tabCompleteNames.length
    else
      delete @tabCompleteCursorIndex
      pieces = text[0...cursorIndex].split(' ')

        @sendChat()
      when 9   # [Tab]
        e.preventDefault()
        @tabComplete($input, reverse: e.shiftKey)
      when 38  # [Up arrow]
        e.preventDefault()
        return  if @chatHistory.length == 0
