JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/[email protected]/dist/react.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.js"></script>
<div id="app">
</div>
CSS
#app {
margin-top: 20px;
}
Babel + JSX
class App extends React.Component {
constructor(props) {
super(props);
this.handleKeyPress = this.handleKeyPress.bind(this);
}
handleKeyPress(e) {
console.log(e.nativeEvent)
console.log(e.nativeEvent.shiftKey)
if (e.nativeEvent.keyCode === 13) {
if(e.nativeEvent.shiftKey){
$('#app').append("<br/> Shift + Enter")
}
}
}
render() {
return ( < textarea defaultValue = {
""
}
onKeyUp = {
this.handleKeyPress
}
onKeyDown = {
this.handleKeyPress
}
/>
);
}
}
ReactDOM.render(<App/>, document.getElementById('app'));