Created
February 10, 2020 20:21
-
-
Save surajitbasak109/376bf5b1ceadfc8bce14078089551727 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hanldeKeyup(evt) { | |
//...more code... | |
} | |
hanldeKeydown(evt) { | |
const { cursor, searchItems } = this.state; | |
// arrow up/down button should select next/previous list element | |
if (evt.keyCode === 38 && cursor > 0) { | |
this.setState(prevState => ({ | |
cursor: prevState.cursor - 1 | |
})); | |
} else if (evt.keyCode === 40 && cursor < searchItems.length - 1) { | |
this.setState(prevState => ({ | |
cursor: prevState.cursor + 1 | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment