Android – How To Override the “Back” button so it doesn’t Finish() my Activity?

I currently have an Activity that when it gets displayed a Notification will also get displayed in the Notification bar. This is so that when the User presses home and the Activity gets pushed to the background they can get back to the Activity via the Notification. The problem arises when a User presses the … Read more

How to handle the `onKeyPress` event in ReactJS?

How can I make the onKeyPress event work in ReactJS? It should alert when enter (keyCode=13) is pressed. var Test = React.createClass({ add: function(event){ if(event.keyCode == 13){ alert(‘Adding….’); } }, render: function(){ return( <div> <input type=”text” id=”one” onKeyPress={this.add} /> </div> ); } }); React.render(<Test />, document.body); 12 Answers 12