react - 綁定鍵盤敲擊回車事件

class App extends Component {

    keypress(e) {

      if (e.which !== 13) return

      console.log('你按了回車鍵...')

    }

    render() {

        return (

            <div>

               <textarea onKeyPress={this.keypress}></textarea>

            </div>

        )

    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章