Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable keyboard in react native

Tags:

react-native

I created a screen keyboard component that I want to disable the platform's keyboard, how I can disable it?

<TextInput
  secureTextEntry
  ref="Pin"
  selectionColor="#656565"
  keyboardType="numeric"
  activeColor="#656565"
  inactiveColor="#fff"
  autoFocus={false}
  ignoreCase
  codeLength={4}
  inputPosition="center"
  size={50}
  onFulfill={isValid => this}
  codeInputStyle={{ borderWidth: 1.5 }}
/>
like image 812
Vaqif Avatar asked Jul 02 '18 11:07

Vaqif


4 Answers

Just write showSoftInputOnFocus={false} in <TextInput> like this:

<TextInput showSoftInputOnFocus={false} />
like image 200
Yashvardhan singh rathore Avatar answered Sep 29 '22 09:09

Yashvardhan singh rathore


I think you need to add something like:

<TextInput showSoftInputOnFocus={false} keyboardType="numeric" />
like image 43
Abdul Rehman Avatar answered Sep 29 '22 08:09

Abdul Rehman


I had issues also. No other solutions was working for me. This will display text input field and it will be clickable but not editable.

<TouchableOpacity onPress={this.openPinKeyboard}>
  <View pointerEvents="none">
    <Input editable={false} value="1234" />
  </View>
</TouchableOpacity>
like image 30
FDisk Avatar answered Sep 29 '22 08:09

FDisk


The easiest solution is to use the onFocus prop on TextInput.

  1. Import Keyboard from ‘react-native’

import {Keyboard, TextInput} from 'react-native'

  1. Then pass Keyboard.dismiss() to TextInput onFocus prop, to stop the keyboard from popping up when focused.

<TextInput onFocus = {()=> Keyboard.dismiss()} .../>

Now test the input field by pressing it to see if the keyboard will pop up

like image 35
Ridwan Ajibola Avatar answered Sep 29 '22 09:09

Ridwan Ajibola