3

I'm developing an inventory system for my father's company and on of its requisites is to be able to use an external Barcode/QR Code scanner.

I've developed everything using the camera as well, but I really need to use the scanner whithout showing the keyboard.

Do any of you guys know if it's possible? if not, can it be done in any other way?

2 Answers2

1

There is a property called showSoftInputOnFocus in newer react-native versions. Setting this to false keeps the keyboard hidden.

<TextInput showSoftInputOnFocus={false} autoFocus={true}..../>

Working for me on v0.60.0

FLash
  • 696
  • 9
  • 27
0

Wrap TouchableOpacity with ScrollView without any props which enables tapto open keyboard work. This Works both on ios and android now!

const [openKeyboard, setOpenKeyboard] = useState(autoFocus);

const onPressInput = useCallback(() => {
    inputRef.current.focus();
    setOpenKeyboard(true)
}, [inputRef]);

  <ScrollView
    >
        <TouchableOpacity
            activeOpacity={1}
            style={[styles.container, style]}
            onPress={onPressInput}

        >
            {renderInputBox()}
            <View style={{ width: 0, height: 0 }}>
                <TextInput
                    keyboardType="numeric"
                    returnKeyType="done"
                    autoFocus={openKeyboard}
                    maxLength={codeLength}
                    ref={inputRef}
                />
            </View>
        </TouchableOpacity>
    </ScrollView>
danklad
  • 88
  • 8