As titled,
I need the backspace event to alter other states in the component.
const onKeyPressHandler = ({ nativeEvent }) => {
if (nativeEvent.key === 'Backspace') {
if (
!TextInputValue.trim() &&
otherstate.length
) {
removeOtherState(otherstate[otherstate.length - 1]);
}
}
};
This code can work on IOS just fine, can trigger backspace even if textinput value becomes empty, but not on Android. The moment the TextInputValue
becomes empty, any backspace keypress will not trigger this handler. Same goes to onChange
and onChangeText
too.
Is there a way to detect backspace key being pressed on the textinput even after the textinput value becomes empty on Android?