I have a search box which is by default not autofocused. So i am putting a keypress event on the body i.e. when forward slash (/) is pressed the search box should be in focus. Although on key press it puts the search box in focus but also puts the "/" in the search box.
body.onkeypress = (e) => {
if(e.which === 47) {
searchInput.focus()
}
}
How should I fix this?