26

How to keep keyboard opened when i have TextInput and Touchable near input that sends message. So i want to send message without double tap on touchable. First to hide keyboard, second to send message. How to do that?

asked Aug 25, 2017 at 14:17
1

4 Answers 4

31

Use keyboardShouldPersistTaps to handle this.

Example:-

<ScrollView
 keyboardDismissMode="on-drag"
 keyboardShouldPersistTaps={'always'} >
</ScrollView>

Deprecated Properties:-

false, deprecated, use 'never' instead

true, deprecated, use 'always' instead

source

RajnishCoder
3,7557 gold badges22 silver badges36 bronze badges
answered Aug 25, 2017 at 15:39
Sign up to request clarification or add additional context in comments.

1 Comment

Don't use true, use 'always', as true is deprecated.
7

Check out keyboardShouldPersistTaps.

The following keeps the keyboard open when content is tapped but closes the keyboard when dragged.

<ScrollView keyboardShouldPersistTaps="always" keyboardDismissMode="on-drag">
 {/* Content containing interactive elements such as <Touchable /> */}
</ScrollView>

Note
Any parent ScrollViews/VirtualizedLists/Flatlists/SectionLists will also need to set keyboardShouldPersistTaps="always"

Here are some gory details if you're interested.

answered Mar 12, 2018 at 3:55

Comments

3

Have a look at the keyboardShouldPersistTaps property of ScrollView. Setting it to "handled" should do what you are looking for.

answered Aug 25, 2017 at 14:23

4 Comments

Why scrollview? I need TouchableHighlight
if you wrap your screen in ScrollView, you can set the keyboard behaviour.
You can add scrollEnabled={false} to disable scrolling if you don't need it.
That's not working. Tried 'always', 'handled' but no one worked for me. Keyboard closes after tapping item in scrollview
0

just only wrap you submit button with scrollview and then make sure u need to add two props keyboardShouldPersistTaps="always" and keyboardDismissMode="on-drag" like this ...

<TextInput/> 
<ScrollView
 contentContainerStyle={{
 width: SIZES.width / 6,
 height: 60,
 }}
 keyboardShouldPersistTaps="always"
 keyboardDismissMode="on-drag">
<TouchableOpacity onPress={}>
</TouchableOpacity>
</ScrollView>
answered Nov 21, 2022 at 5:07

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.