var Grid = require('./Grid'); module.exports = { keydown: function(e) { var x = this.refs.ourhero1.state.x; var y = this.refs.ourhero1.state.y; switch (e.keyCode) { case 32: this.munch(x, y); break; case 37: // Left arrow if (x > 0) { this.refs.ourhero1.setState({ x: x - 1 }); } break; case 38: // Up arrow if (y > 0) { this.refs.ourhero1.setState({ y: y - 1 }); } break; case 39: // Right arrow x < 2 ? this.refs.ourhero1.setState({ x: x + 1 }) : this.refs.ourhero1.setState({ x: 0 }) break; case 40: // Down arrow if (y < 2) { this.refs.ourhero1.setState({ y: y + 1 }); } } } };