                 allPartialMatchesContainKeyupRemainder = false
             break if allPartialMatchesContainKeyupRemainder is false
           else
-            queuedKeystrokes = null
+            shouldUsePartialMatches = false
 
           if @dispatchCommandEvent(exactMatchCandidate.command, target, event)
             @emitter.emit 'did-match-binding', {

  #
  # * `event` A `KeyboardEvent` of type 'keydown'
  handleKeyboardEvent: (event, {replay, disabledBindings}={}) ->
    eventResult = @_handleKeyboardEvent(event, @queuedKeystrokes, disabledBindings)
    return unless eventResult?
    {keystroke, dispatchedBinding, queuedKeystrokes, exactMatch, partialMatches} = eventResult

    hasPartialMatches = partialMatches? and partialMatches.length > 0

    @queuedKeystrokes.push(keystroke)
    @queuedKeyboardEvents.push(event)
    @bindingsToDisable.push(dispatchedBinding) if dispatchedBinding

    if queuedKeystrokes? and hasPartialMatches
      enableTimeout = (
        @pendingStateTimeoutHandle? or
        exactMatch? or
        characterForKeyboardEvent(@queuedKeyboardEvents[0])?
      )
      enableTimeout = false if replay
      @enterPendingState(partialMatches, enableTimeout)
    else if not exactMatch? and not hasPartialMatches and @pendingPartialMatches?
      @terminatePendingState()
    else
      @clearQueuedKeystrokes()

  # This function does not set any state. State is handled in the
  # `handleKeyboardEvent` function.
  _handleKeyboardEvent: (event, queuedKeystrokes=[], disabledBindings) ->
    keystroke = @keystrokeForKeyboardEvent(event)

    if event.type isnt 'keyup' and queuedKeystrokes.length > 0 and isAtomModifier(keystroke)
      event.preventDefault()
      return

    # If the event's target is document.body, assign it to defaultTarget instead
    # to provide a catch-all element when nothing is focused.
    target = event.target
    target = @defaultTarget if event.target is document.body and @defaultTarget?

    queuedKeystrokes = queuedKeystrokes.concat([keystroke])
    keystrokes = queuedKeystrokes.join(' ')

    # First screen for any bindings that match the current keystrokes,
    # regardless of their current selector. Matching strings is cheaper than
    # matching selectors.
    {partialMatchCandidates, keydownExactMatchCandidates, exactMatchCandidates} = @findMatchCandidates(queuedKeystrokes, disabledBindings)
    exactMatch = null
    dispatchedBinding = null
    partialMatches = @findPartialMatches(partialMatchCandidates, target)

    # Determine if the current keystrokes match any bindings *exactly*. If we
    # do find and exact match, the next step depends on whether we have any

      # simulate the text input event that was previously prevented to insert
      # the missing characters.
      @simulateTextInput(event) if event.defaultPrevented and event.type is 'keydown'

    if hasPartialMatches and shouldUsePartialMatches
      event.preventDefault()

      enableTimeout = (
        @pendingStateTimeoutHandle? or
        dispatchedExactMatch? or
        characterForKeyboardEvent(@queuedKeyboardEvents[0])?
      )
      enableTimeout = false if replay
      @enterPendingState(partialMatches, enableTimeout)

      @emitter.emit 'did-partially-match-binding', {
        keystrokes,
        eventType: event.type,
        partiallyMatchedBindings: partialMatches,
        keyboardEventTarget: target
      }
    else if not dispatchedExactMatch? and not hasPartialMatches and @pendingPartialMatches?
      # There are partial matches from a previous event, but none from this
      # event. This means the current event has removed any hope that the queued
      # key events will ever match anything. So we will clear the state and
      # start over after replaying the events in `terminatePendingState`.
      @terminatePendingState()
    else
      @clearQueuedKeystrokes()

  # Public: Translate a keydown event to a keystroke string.
  #
