src/plugins/keyboard.js
function moveHighlight(dropdown, delta) {
        var results = dropdown.results;
        if (!results.length) {
            return;
        }

        var resultItems = [].slice.call(dropdown.el.querySelectorAll('.selectivity-result-item'));

        function scrollToHighlight() {
            var el;
            if (dropdown.highlightedResult) {
                el = findResultItem(resultItems, dropdown.highlightedResult.id);
            } else if (dropdown.loadMoreHighlighted) {
                el = dropdown.$('.selectivity-load-more');
            }

            if (el && el.scrollIntoView) {
                el.scrollIntoView(delta < 0);
            }
        }

        if (dropdown.submenu) {
            moveHighlight(dropdown.submenu, delta);
            return;
        }

        var defaultIndex = delta > 0 ? 0 : resultItems.length - 1;
        var index = defaultIndex;
        var highlightedResult = dropdown.highlightedResult;
        if (highlightedResult) {
            var highlightedResultItem = findResultItem(resultItems, highlightedResult.id);
            index = resultItems.indexOf(highlightedResultItem) + delta;
            if (delta > 0 ? index >= resultItems.length : index < 0) {
                if (dropdown.hasMore) {
                    dropdown.highlightLoadMore();
                    scrollToHighlight();
                    return;
                } else {
                    index = defaultIndex;
                }
            }
        }

        var resultItem = resultItems[index];
        var result = Selectivity.findNestedById(results, selectivity.getRelatedItemId(resultItem));
        if (result) {
            dropdown.highlight(result, { delay: !!result.submenu });
            scrollToHighlight();
        }
    }
function moveHighlight(dropdown, delta) {
        var results = dropdown.results;
        if (!results.length) {
            return;
        }

        var resultItems = [].slice.call(dropdown.el.querySelectorAll('.selectivity-result-item'));

        function scrollToHighlight() {
            var el;
            if (dropdown.highlightedResult) {
                el = findResultItem(resultItems, dropdown.highlightedResult.id);
            } else if (dropdown.loadMoreHighlighted) {
                el = dropdown.$('.selectivity-load-more');
            }

            if (el && el.scrollIntoView) {
                el.scrollIntoView(delta < 0);
            }
        }

        if (dropdown.submenu) {
            moveHighlight(dropdown.submenu, delta);
            return;
        }

        var defaultIndex = delta > 0 ? 0 : resultItems.length - 1;
        var index = defaultIndex;
        var highlightedResult = dropdown.highlightedResult;
        if (highlightedResult) {
            var highlightedResultItem = findResultItem(resultItems, highlightedResult.id);
            index = resultItems.indexOf(highlightedResultItem) + delta;
            if (delta > 0 ? index >= resultItems.length : index < 0) {
                if (dropdown.hasMore) {
                    dropdown.highlightLoadMore();
                    scrollToHighlight();
                    return;
                } else {
                    index = defaultIndex;
                }
            }
        }

        var resultItem = resultItems[index];
        var result = Selectivity.findNestedById(results, selectivity.getRelatedItemId(resultItem));
        if (result) {
            dropdown.highlight(result, { delay: !!result.submenu });
            scrollToHighlight();
        }
    }
function moveHighlight ( dropdown , delta ) { var results = dropdown . results ; if ( ! results . length ) { return ; } var resultItems = [ ] . slice . call ( dropdown . el . querySelectorAll ( '.selectivity-result-item' ) ) ; function scrollToHighlight ( ) { var el ; if ( dropdown . highlightedResult ) { el = findResultItem ( resultItems , dropdown . highlightedResult . id ) ; } else if ( dropdown . loadMoreHighlighted ) { el = dropdown . $ ( '.selectivity-load-more' ) ; } if ( el && el . scrollIntoView ) { el . scrollIntoView ( delta < 0 ) ; } } if ( dropdown . submenu ) { moveHighlight ( dropdown . submenu , delta ) ; return ; } var defaultIndex = delta > 0 ? 0 : resultItems . length - 1 ; var index = defaultIndex ; var highlightedResult = dropdown . highlightedResult ; if ( highlightedResult ) { var highlightedResultItem = findResultItem ( resultItems , highlightedResult . id ) ; index = resultItems . indexOf ( highlightedResultItem ) + delta ; if ( delta > 0 ? index >= resultItems . length : index < 0 ) { if ( dropdown . hasMore ) { dropdown . highlightLoadMore ( ) ; scrollToHighlight ( ) ; return ; } else { index = defaultIndex ; } } } var resultItem = resultItems [ index ] ; var result = Selectivity . findNestedById ( results , selectivity . getRelatedItemId ( resultItem ) ) ; if ( result ) { dropdown . highlight ( result , { delay : ! ! result . submenu } ) ; scrollToHighlight ( ) ; } }
Moves a dropdown's highlight to the next or previous result item.

@param delta Either 1 to move to the next item, or -1 to move to the previous item.
Moves a dropdown s highlight to the next or previous result item .