/** * THIS is the Board class. */ module.exports = { keydown(e) { var x = this.refs.muncher.state.x; var y = this.refs.muncher.state.y; switch (e.keyCode) { case 32: this.refs.grid.munch(x, y); break; case 37: // Left arrow if (x > 0) { this.refs.muncher.setState({ x: x - 1 }); } break; case 38: // Up arrow if (y > 0) { this.refs.muncher.setState({ y: y - 1 }); } break; case 39: // Right arrow if (x < this.refs.grid.props.width - 1) { this.refs.muncher.setState({ x: x + 1 }); } break; case 40: // Down arrow if (y < this.refs.grid.props.height - 1) { this.refs.muncher.setState({ y: y + 1 }); } } } };