How to scroll the list using arrowkeys?

I have a search box and search result. on keypress the mouse cursor moves but it goes beyond the searchresult container without moving the list. So I want to know how can I scroll the list along with the cursor.

after lot of research, I have come to understand that it can be achieved using refs but I don’t understand them well.

i have tried this code and it moves the entire page while I need to move just search results


Note : I am not using any library. Just building from scratch.

Not sure if this is just me, but I am struggling to understand the question. For example what is a search box? (Do you mean textarea?)
Or what is a search result? You said “scroll the list” but what did you mean?

you might have seen searchboxes on most of the websites to search item. It’s just an input and on entering the value it shows suggestions like google. Just refer the google searchbox

If you are not using a library (React), then I do not believe myRef.current will help you. Can you please post a link to your full code, so we can test it out? If you have it on Codepen, that will work also.