I am working on a text input box with auto-complete options displayed below it. I want to enable users to navigate through the options using keyboard arrows and "select" one, causing it to change color. How can I update the text in the input box with the selected option, similar to what search engines do?
<input class="searchBox" id="searchBox" name="q" type="text" autocomplete="off" placeholder="hi">
<div class="autoSuggestContainer">
<span>Select from Menu</span>
<a>history</a>
<a>hilton</a>
<a>hip2save</a>
<a>hillary clinton</a>
<a>hickok45</a>
<a>hitler</a>
<a>hibiscus</a>
<a>hipaa</a>
</div>
For the full code including HTML, CSS, and Javascript implementation, you can access it via this link: https://jsfiddle.net/qckyu5e6/