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 if (x < this.props.width - 1) { this.refs.ourhero1.setState({ x: x + 1 }); } break; case 40: // Down arrow if (y < this.props.height - 1) { this.refs.ourhero1.setState({ y: y + 1 }); } } } };