6

When i press an input in react-native , the keyboard pops an opens. I would like to close the keyboard (ONLY) when pressing some button. How can i do this?

1 Answer 1

20

You can dismiss the keyboard by using Keyboard.dismiss.

import { Keyboard } from 'react-native'; <Touchable onPress={Keyboard.dismiss}>...</Touchable> 

If you're using a ScrollView you'll need to set keyboardShouldPersistTaps prop to true.

Sign up to request clarification or add additional context in comments.

3 Comments

Working perfectly!
@oblador did you mean this one: react-native-dismiss-keyboard when you wrote from 'dismissKeyboard'?
What if we are using a FlatList inside ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.