如何在ReactJS中的onKeyPress事件中检测到'Shift + Enter'键盘组合?

9 浏览
0 Comments

如何在ReactJS中的onKeyPress事件中检测到'Shift + Enter'键盘组合?

如何在ReactJS的onKeyPress事件中检测到'Shift + Enter'?这是否可能?[链接](https://jsfiddle.net/jacobgoh101/cyLqfcts/3/)

class App extends React.Component {
  constructor(props) {
    super(props);
    this.handleKeyPress = this.handleKeyPress.bind(this);
  }
  handleKeyPress(e) {
    console.log(e.key);
    $('#app').append("" + e.key);
  }
  render() {
    return (