I want to be able to hit the enter button on the keyboard, keep focus on the TextInput
, and keep the keyboard open. How can this be done?
The answers about ScrollView
implmentation refer to touching a button outside of the TextInput
as opposed to actually hitting the return key on the keyboard.
I want to be able to hit the enter button on the keyboard, keep focus on the TextInput
, and keep the keyboard open. How can this be done?
The answers about ScrollView
implmentation refer to touching a button outside of the TextInput
as opposed to actually hitting the return key on the keyboard.
- Could you provide some code – Subramanya Chakravarthy Commented Dec 20, 2017 at 2:12
1 Answer
Reset to default 24The way to do this on a TextInput
is to set blurOnSubmit={false}
and then use onSubmitEditing
as the submit handler instead of onEndEditing
.
onTextChange(input) {
this.setState({ value: input })
}
submitValue() {
// Do things with the value
...
// Then reset it so the TextInput can be reused
this.setState({ value: '' })
}
<TextInput
blurOnSubmit={false}
style={styles.inputBox}
onChangeText={input => this.onTextChange(input)}
onSubmitEditing={() => this.submitValue(this.state.value)}
value={this.state.value}
/>
On pressing of the return key this.setState({ value: '' })
to clear the text from the TextInput
.