I am trying to handle an event when the user presses the Backspace button.
I saw this, and I guess I can find Backspace key code using
console.log(\"Did y
You have to listen to the onKeyDown
event to capture the delete action.
Example:
var InputDemo = React.createClass({
getInitialState: function() {
return {
message: ''
};
},
onKeyDown: function(e) {
if (e.keyCode === 8) {
console.log('delete');
}
},
handleChange: function(e) {
this.setState({
message: e.target.value
});
},
render: function() {
return (
);
}
});
Running fiddle: https://jsfiddle.net/7eu41pzz/1/