Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onKeyPress method on TextInput for Android

I've been trying to catch the keyboard's events within a TextInput in react-native.

By reading the component's doc (https://facebook.github.io/react-native/docs/textinput.html) I noticed the onKeyPress function which fits perfectly what I need. But it is labelled as ios only. I haven't found anything about an android workaround except this issue (https://github.com/facebook/react-native/issues/1882) which has been inactive for a couple months now ...

What I'd need to do is calling a specific method when Backspace is pressed and it looks like it can only be done for ios for now ...

Do you guys know any workaround for this ?

Thanks in advance :)

like image 726
Guillaume Munsch Avatar asked Mar 30 '17 15:03

Guillaume Munsch


1 Answers

onKeyPress is now supported on Android.

From version v0.55.2 (commit)

Note hat the hardware keyboard inputs are not supported on Android, only the soft keyboard inputs.

Meaning, if you test this on an Android emulator and you type on your computer keyboard, those inputs are not be handled. So, go ahead and press the soft keyboard on the emulator with the mouse.

like image 189
Gianfranco P. Avatar answered Oct 30 '22 22:10

Gianfranco P.