function downArrowSimulator(input) {
	// eslint-disable-next-line no-underscore-dangle -- Is old style should be analyzed
	const _addEventListener = input.addEventListener ? input.addEventListener : input.attachEvent;

	/**
	 * Add event listener wrapper that will replace to default addEventListener or attachEvent function
	 *
	 * @param  {string} type the event type
	 * @param  {Function} listener function should be executed when the event is fired
	 * @returns {void}
	 */
	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') {
			const origListener = listener;
			// eslint-disable-next-line no-param-reassign -- Is old style this should be analyzed
			listener = (event) => {
				const suggestionSelected = document
					? document.getElementsByClassName('pac-item-selected').length > 0
					: null;
				if (event.which === 13 && !suggestionSelected) {
					const simulatedEvent = document.createEvent('Event');
					simulatedEvent.keyCode = 40;
					simulatedEvent.which = 40;
					origListener.apply(input, [simulatedEvent]);
				}
				origListener.apply(input, [event]);
			};
		}
		_addEventListener.apply(input, [type, listener]);
	}

	input.addEventListener = addEventListenerWrapper;
	input.attachEvent = addEventListenerWrapper;
}
This function simulates a down arrow key event when user
hits return (enter) on the autocomplete component selection
the first occurrence in the list.

This piece of code was orignally written by amirnissim
and has been ported to Vanilla.js by GuillaumeLeclerc
@see http://stackoverflow.com/a/11703018/2694653

@param  {Object} input the HTML input node element reference
@returns {void}