Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i want keyboard not to show up at all when i touch my text input-React-Native

Tags:

react-native

I want keyboard not to show up at all when i touch my text input.If i use 'Keyboard.dismiss' i loose the focus on my text input i am using custom keyboard which itself is part of my screen so i don't want any keyboard to show up at all without loosing the focus on my text input, any solution please.I have tried using libraries but facing same problems again and again what should i do. Here the code i Am using

<TextInput onFocus={Keyboard.dismiss}>

enter image description here

like image 712
Devansh Sanghvi Avatar asked Jul 26 '17 09:07

Devansh Sanghvi


People also ask

How do I hide the keyboard in React Native?

If you have something other than a ScrollView and you'd like any presses to dismiss the keyboard, you can use a simple TouchableWithoutFeedback and have the onPress use React Native's utility library dismissKeyboard to dismiss the keyboard for you.

How do I turn off keyboard input in react?

Material-UI's <TextField> is a wrapper around react's <input> , so all you need to do is pass onKeyDown down via inputProps , which you are already using to pass min , max , and defaultValue . const [value, setValue] = useState(10); return ( <React.

How do you not open the keyboard on TextInput in React Native?

Use <TextInput showSoftInputOnFocus={false} /> It will hide the keyboard when you focus on the text input. Save this answer.

How do you close keyboard on click in React Native?

In react native the Keyboard. dismiss() method is used to hide the keyboard or soft keypad, touchpad on a certain click event.


2 Answers

Use <TextInput showSoftInputOnFocus={false} /> It will hide the keyboard when you focus on the text input.

like image 62
Aniket Avatar answered Oct 13 '22 09:10

Aniket


ReactNative TextInput has showSoftInputOnFocus prop, which is due to docs should hide keyboard. But seems like it doesn't work.

I found this solution, works for me:

 <>
<TouchableWithoutFeedback onPress={this.toggleVisible}>
  <View>
    <View pointerEvents="none">
      <Input
        value={String(value)}
        placeholder={placeholder}
      />
    </View>
  </View>
</TouchableWithoutFeedback>
<DateTimePicker
  isVisible={this.state.visible}
  onConfirm={onChange}
  onCancel={this.toggleVisible}
/>

like image 26
dima bgood Avatar answered Oct 13 '22 07:10

dima bgood