I have component where it displays questions . Each question is react component. On press of Enter it should navigate to next question. I have wired onKeyPress to Div element , but event gets captured sometimes , and sometimes it doesn't.
<div className="-" onKeyPress={(e) => this.navigateToNext(e)}>
<div className="preview-head">
//Other stuff here
</div>{/* preview-container*/}
</div>
navigateToNext(e) {
if (option.get('selected') === true && e.charCode === 13) {
this.goToNextQuestion();
}
}
Can anyone tell me any other way to handle this problem.