JSFiddle - React, Tailwind, and code Playground
by redbmk
HTML
<script src="http://cdn.craftycomponents.com/crafty-dev.js"></script>
JavaScript
// Init Crafty:
Crafty.init();
Crafty.canvas.init();
Crafty.e("2D, Canvas, Color, Twoway")
.attr({x: 0, y: 0, w: 50, h: 50, paused: false})
.twoway(1)
.color("rgb(0,255,0)")
.bind('KeyDown', function (e) {
if (e.key === Crafty.keys.SPACE) {
this.paused = !this.paused;
if (this.paused) {
this.disableControl();
} else {
this.enableControl();
}
}
});