Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpragliola/a73a483b6761519d124d51d04156aab3 to your computer and use it in GitHub Desktop.
Save mpragliola/a73a483b6761519d124d51d04156aab3 to your computer and use it in GitHub Desktop.
Konami code with RxJs Observables
const keys$ = Rx.Observable.fromEvent(document, 'keyup')
.map(ev => ev.code)
.bufferCount(10, 1)
.map(codes => codes.join(','))
.filter(codes => codes === "ArrowUp,ArrowUp,ArrowDown,ArrowDown,ArrowLeft,ArrowRight,ArrowLeft,ArrowRight,KeyB,KeyA");
keys$
.subscribe(
x => console.log('KONAMI!')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment