问题
I am trying to find this answer, but all the other questions I have found are React Native.
`handleEnter(e){
if(e.key == 'Enter'){
//REMOVE KEYBOARD
}
}`
Also my input is a text search. So I want the keyboard to hide so users can see the results that come up.
回答1:
e.target
is the focused input
or textarea
where the user is writhing. When he click on Enter
the focused input
became unfocused and so the keyboard disappear
`handleEnter(e){
if(e.key == 'Enter'){
e.target.blur();
}
}`
来源:https://stackoverflow.com/questions/53006913/in-regular-react-how-to-dismiss-mobile-keyboards-on-submit-or-enter-key