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?

asked Jun 27, 2016 at 14:19

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.

answered Jun 27, 2016 at 17:54
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 ?

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.