Skip to content

Instantly share code, notes, and snippets.

@drFabio
Created December 27, 2017 13:06
Show Gist options
  • Save drFabio/6accf0d55b2bf945173d933d5a5ed4b5 to your computer and use it in GitHub Desktop.
Save drFabio/6accf0d55b2bf945173d933d5a5ed4b5 to your computer and use it in GitHub Desktop.
_listenToKey(ev) {
if (ev.code === 'Enter') {
if (!this.state.running) {
this._startGame()
}
}
if (this.state.running) {
if (ev.code === 'Space' || ev.code === 'ArrowUp') {
this._controls.up++
}
if (ev.code === 'AltRight' || ev.code === 'ControlLeft' || ev.code === 'AltLeft' || ev.code === 'ControlRight' || ev.code === 'ArrowDown') {
this._controls.down++
}
if (ev.code === 'ArrowRight') {
this._controls.right++
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment