识别React Native中的Return Key操作 [英] Identify Return Key action in React Native
本文介绍了识别React Native中的Return Key操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个TextInput
,我已将multiline
启用为true.问题是按回车键后键盘不会隐藏.转到新的一行.因此,我希望使用 react-native-dismiss-keyboard .要利用此漏洞,我需要确定Return键动作.该怎么做?
I have a TextInput
which I have enabled multiline
as true. Thing is the Keyboard won't hide after Return is pressed. It goes to a new line. So I was hoping to use react-native-dismiss-keyboard. To exploit this I need to identify the Return key action. How to do this?
<TextInput
style={styles.additionalTextInput}
multiline={true}
autoCapitalize="sentences"
autoCorrect={true}
onChangeText={(text) => this.setState({text})}
keyboardType="default"
returnKeyType="done"
onKeyPress={(keyPress) => console.log(keyPress)}
placeholder="Enter text here..."
/>
推荐答案
我使用的是onSubmitEditing
道具.例如
<TextInput style={[styles.textInput]}
placeholder='搜索'
placeholderTextColor='#bbb'
onChange={(event) => {
this.searchChange(event.nativeEvent.text)
}}
returnKeyType='search'
autoFocus={true}
value={ this.props.searchName }
selectionColor={colors.orangeColor}
onSubmitEditing={this.searchSubmit}
clearButtonMode="while-editing"
/>
这篇关于识别React Native中的Return Key操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文