How to detect 'Shift + Enter' in ReactJS onKeyPress event? How to detect 'Shift + Enter' in ReactJS onKeyPress event? reactjs reactjs

How to detect 'Shift + Enter' in ReactJS onKeyPress event?


Your answer is detecting on 'Enter' not 'Shift+Enter'. This should help!https://jsfiddle.net/Pranesh456/c2hzt27g/3/

class App extends React.Component {  constructor(props) {    super(props);    this.handleKeyPress = this.handleKeyPress.bind(this);  }  handleKeyPress(e) {    if (e.key === 'Enter' && e.shiftKey) {               $('#app').append("<br/> Detected Shift+Enter")    }  }  render() {    return (      <textarea         defaultValue = {""}        onKeyUp={this.handleKeyPress}      />    );  }}ReactDOM.render(<App/>, document.getElementById('app'));