Reputation: 113
How to detect typed character is the backspace/delete
if (e.nativeEvent.key === 'Backspace')
tried this but not working
Upvotes: 10
Views: 12637
Reputation: 19049
https://facebook.github.io/react-native/docs/textinput#onkeypress
<TextInput
onKeyPress={({ nativeEvent }) => {
if (nativeEvent.key === 'Backspace') {
...doTheMagic();...
}
}}
/>
Live example: https://snack.expo.io/@zvona/backspace
Upvotes: 35