         @_searchFor e.currentTarget.value
       , false
 
-      @el.addEventListener 'keypress', (e) =>
+      @el.addEventListener 'keydown', (e) =>
         if @showingList
           @_handleKeypress e
 
-      # this needs to be fixed - doesn't pick up span click
       @el.parentNode.addEventListener 'click', (e) =>
-        if e.target.tagName == 'LI'
-          @el.value = e.target.textContent
-          @_removeResults()
+        if e.target.tagName == 'A'
+          if e.target.getAttribute('href') == '#'
+            e.preventDefault()
+            @el.value = e.target.textContent
+            @_removeResults()
 
     _handleKeypress: (e) ->
+      console.log e
       if e.keyCode == 40 # down arrow
         e.preventDefault()
         @_highlightDown()

    _searchFor: (searchTerm)  ->
      if searchTerm && searchTerm.length >= 3
        @searchTerm = searchTerm

        if not @throttled
          @_doRequest @searchTerm

      else if @showingList
        @_removeResults()

    _doRequest: ->
      myRequest = new XMLHttpRequest()
      myRequest.addEventListener 'readystatechange', =>
        if myRequest.readyState == 4
          if myRequest.status == 200
            @_updateUI JSON.parse myRequest.responseText

      myRequest.open 'get', @_generateURI(@args.uri, @args.scope)
      myRequest.setRequestHeader 'Accept', '*/*'
      myRequest.send()
      @throttled = true
      window.setTimeout =>
        @throttled = false
      , 200

    _generateURI: (searchURI, scope) ->
      uri = "#{searchURI}#{@searchTerm}"


    _highlightText: (text, term) ->
      regex = new RegExp term, 'ig'
      text.replace regex, "<b>$&</b>"
