Force Javascript keydown on autocomplete input Google Maps!

0

Personal I have the following problem I need when I click "Enter" on an input with auto complete of Google Maps, then it press the down key to select a Google Maps option .. tried in several ways more did not work out ! I have the following code:

jQuery('.find-by__autocomplete').on('keydown', function(e) {
    if(e.keyCode == 13) {
        e.which = 40;
        jQuery(".find-by__autocomplete").trigger(e);
    }
});

Thank you!

    
asked by anonymous 07.03.2018 / 21:32

1 answer

0

Solved as follows!

jQuery("#autocomplete").keypress(function (e) {
    e.cancelBubble = true;

    if (e.keyCode === 13 || e.keyCode === 9) {
        google.maps.event.trigger(e.target, "keydown", {
            keyCode: 40,
            hasRanOnce: true
        });

        google.maps.event.trigger(e.target, "keydown", {
            keyCode: 13,
            hasRanOnce: true
        });
    }
});
    
09.03.2018 / 18:07