We have a React Native TextInput component in our app. Using the virtual keyboard, pressing enter creates a new line. If we use a hardware keyboard (attached to an Android 6 tablet using an USB OTG adapter), the Enter key (the large one in the middle of the keyboard) doesn't change the text, the TextInput only loses the focus. The Return key (the smaller one on the right side of common keyboards) creates a new line.
The TextInput is setup very basic:
<TextInput multiline={true} />
I tried different values for the returnKeyType attribute, but none of them created a new line. Am I missing something?
You can setup your TextInput with multiline and blurOnSubmit to false. This will keep the keyboard and allow multiline in the input. And use the onKeyPress props only for sending a message. This should work in both Android and iOS.
The easiest solution is to use the onFocus prop on TextInput. Then pass Keyboard. dismiss() to TextInput onFocus prop, to stop the keyboard from popping up when focused.
You're welcome: blurOnSubmit={true}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With