Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Google Places select first on Enter

var selectFirstOnEnter = function(input) {  // store the original event binding function
    var _addEventListener = (input.addEventListener) ? input.addEventListener : input.attachEvent;
    function addEventListenerWrapper(type, listener) {  // Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected, and then trigger the original listener.
        if (type == "keydown") { 
            var orig_listener = listener;
            listener = function(event) {
                var suggestion_selected = $(".pac-item-selected").length > 0;
                if (event.which == 13 && !suggestion_selected) { 
                    var simulated_downarrow = $.Event("keydown", {keyCode: 40, which: 40}); 
                    orig_listener.apply(input, [simulated_downarrow]); 
                }
                orig_listener.apply(input, [event]);
            };
        }
        _addEventListener.apply(input, [type, listener]); // add the modified listener
    }
    if (input.addEventListener) { 
        input.addEventListener = addEventListenerWrapper; 
    } else if (input.attachEvent) { 
        input.attachEvent = addEventListenerWrapper; 
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: xjavascript 
Javascript :: generator in classs js 
Javascript :: why my style not come to angular 11 
Javascript :: rotation in p5 play 
Javascript :: manipulação de array javascript 
Javascript :: message.author 
Javascript :: how to bind a json output result to any new model 
Javascript :: renderIndicator example react responsive carousel 
Javascript :: jqgrid add edit or add options 
Javascript :: open close children modal react 
Javascript :: currentVal 
Javascript :: how can we give the index of an array as an ID to an element 
Javascript :: how to get the data from clicking on notification on web in reactjs 
Javascript :: how to merge duplicate value in array of object site:stackoverflow.com 
Javascript :: Gif Animation on Image jquery 
Javascript :: enviroment variable not getting recognised in NuxtJS 
Javascript :: onload page data 
Javascript :: passar a página atual na url js net core 
Javascript :: immediate invoke jquery arrow function 
Javascript :: react native typescript nodejs timeout 
Javascript :: debounce="300" 
Javascript :: liquid indicators in react native 
Javascript :: google script isnan 
Javascript :: join-an-array-by-a-comma-and-a-space 
Javascript :: 9.5. The Accumulator Pattern¶ 
Javascript :: captureEvents 
Javascript :: element.queryselector possibly null 
Javascript :: https://stackoverflow.com/questions/51115640/how-to-send-form-data-from-react-to-express/51116082 
Javascript :: Multiple destinations with gulp js 
Javascript :: .chartjs-render-monitor 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =