src/amazon-autocomplete.js
function _processOnKeyUp(evt) {
        let key = evt.keyCode || evt.which;
        let char = String.fromCharCode(key);
        let self = this;
        if (key === 38) {
            if (self._idx > 0) {
                _unselectWord(self._words[self._idx]);
                self._idx--;
            }
            self._words[self._idx].className += ' ac__word--selected';
        } else if (key == 40) {
            if (self._idx < self._words.length - 1) {
                _unselectWord(self._words[self._idx]);
                self._idx++;
            }
            self._words[self._idx].className += ' ac__word--selected';
        } else if (key == 13) {
            if (self._words.length && self._idx > -1)
                self._onSelectedCB(_getStringFromWordElement(self._words[self._idx]));
            else
                self._onSelectedCB(self._input.value);
        } else if (/[a-zA-Z0-9-_ ]/.test(char) || key === 8) {
            self._idx = -1;
            let prefix = self._input.value;
            if (prefix != '')
                self._keyListenerDebounced(prefix);
            else
                _flushWordsContainer.call(self);
        }
    }
function _processOnKeyUp(evt) {
        let key = evt.keyCode || evt.which;
        let char = String.fromCharCode(key);
        let self = this;
        if (key === 38) {
            if (self._idx > 0) {
                _unselectWord(self._words[self._idx]);
                self._idx--;
            }
            self._words[self._idx].className += ' ac__word--selected';
        } else if (key == 40) {
            if (self._idx < self._words.length - 1) {
                _unselectWord(self._words[self._idx]);
                self._idx++;
            }
            self._words[self._idx].className += ' ac__word--selected';
        } else if (key == 13) {
            if (self._words.length && self._idx > -1)
                self._onSelectedCB(_getStringFromWordElement(self._words[self._idx]));
            else
                self._onSelectedCB(self._input.value);
        } else if (/[a-zA-Z0-9-_ ]/.test(char) || key === 8) {
            self._idx = -1;
            let prefix = self._input.value;
            if (prefix != '')
                self._keyListenerDebounced(prefix);
            else
                _flushWordsContainer.call(self);
        }
    }
function _processOnKeyUp ( evt ) { let key = evt . keyCode || evt . which ; let char = String . fromCharCode ( key ) ; let self = this ; if ( key === 38 ) { if ( self . _idx > 0 ) { _unselectWord ( self . _words [ self . _idx ] ) ; self . _idx -- ; } self . _words [ self . _idx ] . className += ' ac__word--selected' ; } else if ( key == 40 ) { if ( self . _idx < self . _words . length - 1 ) { _unselectWord ( self . _words [ self . _idx ] ) ; self . _idx ++ ; } self . _words [ self . _idx ] . className += ' ac__word--selected' ; } else if ( key == 13 ) { if ( self . _words . length && self . _idx > - 1 ) self . _onSelectedCB ( _getStringFromWordElement ( self . _words [ self . _idx ] ) ) ; else self . _onSelectedCB ( self . _input . value ) ; } else if ( / [a-zA-Z0-9-_ ] / . test ( char ) || key === 8 ) { self . _idx = - 1 ; let prefix = self . _input . value ; if ( prefix != '' ) self . _keyListenerDebounced ( prefix ) ; else _flushWordsContainer . call ( self ) ; } }
Listen to a keyup event on the search input. This function will handle navigation
inside the words ui widget by listening to up and down arrows.

@param {event} evt - Keyup event
Listen to a keyup event on the search input . This function will handle navigation inside the words ui widget by listening to up and down arrows .