Published
- 1 min read
onEnter input field react
The solution for this is noted below
onEnter input field react
Solution
<input
onKeyPress={(e) => {
if (e.key === 'Enter') {
this.setState({ message: e.target.value }, () => {
alert(this.state.message)
})
}
}}
type='text'
/>
Try other methods by searching on the site. That is if this doesn’t work