Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native onKeyPress is not working?

Tags:

react-native

I have just placed TextInput KeyboardType ={"numeric"} just trying to find weather user enter '-' if means I have to event.preventDefault() in OnChange first.Later tried in onKeyPress but onKeyPress is not trigerring , I was just tried to do that but it allowing me to type shows warning Synthetic Event Performance issue.

guys help me .

like image 961
saiRam89 Avatar asked Dec 19 '22 05:12

saiRam89


1 Answers

You are testing with android mobile whereasonKeyPress method is for iOS, check documentation for same

You can use onChangeText for text change.

Example:

<TextInput
    onChangeText={(text) => this.onFirstNameText(text)}
    returnKeyType={'next'}
    underlineColorAndroid='transparent'
    style={styles.inputColLeft}
/>

Edit 2018

onKeyPress is now also supported for Android devices as per this commit.

From doc:

Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs.

like image 114
Jigar Shah Avatar answered Mar 16 '23 16:03

Jigar Shah