In this episode, we tackle improving keyboard navigation for our search results. Up until now, users could type in their query and click on a result, but if you tried to use the keyboard to navigate the results and hit Enter, nothing happened—definitely not ideal!
So, we walk through how to fix this by implementing a getItemURL
function for our results. This function simply extracts the URL from the selected item so the search package knows where to navigate when you hit Enter on a highlighted result.
We apply this for both our regular results and our courses, taking advantage of common property names to keep things simple. Once that's done, keyboard navigation just works: you can arrow down to a result and press Enter to go straight to that item's page—way more accessible and user-friendly!
Overall, this little tweak makes searching smoother for everyone, especially those who prefer to navigate with their keyboard.