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
            
        
        
            Active
            
        
            Viewed 2.1k times
        
    23
            
            
        
        IC_
        
- 1,624
 - 1
 - 23
 - 57
 
- 
                    1Possible duplicate of [React Native have to double click for onPress to work](https://stackoverflow.com/questions/42808294/react-native-have-to-double-click-for-onpress-to-work) – WayneC Aug 25 '17 at 14:51
 
4 Answers
29
            
            
        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
        RajnishCoder
        
- 3,455
 - 6
 - 20
 - 35
 
        csath
        
- 1,248
 - 11
 - 25
 
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"
        GollyJer
        
- 23,857
 - 16
 - 106
 - 174
 
3
            
            
        Have a look at the keyboardShouldPersistTaps property of ScrollView. Setting it to "handled" should do what you are looking for.
        WayneC
        
- 5,569
 - 2
 - 32
 - 43
 
- 
                    1
 - 
                    if you wrap your screen in ScrollView, you can set the keyboard behaviour. – WayneC Aug 25 '17 at 14:45
 - 
                    You can add `scrollEnabled={false}` to disable scrolling if you don't need it. – WayneC Aug 25 '17 at 14:48
 - 
                    8That's not working. Tried 'always', 'handled' but no one worked for me. Keyboard closes after tapping item in scrollview – IC_ Aug 27 '17 at 03:26
 
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>
        faery
        
- 61
 - 2
 - 5