Skip to content

Instantly share code, notes, and snippets.

@m1m1s1ku
Last active June 10, 2018 22:06
Show Gist options
  • Save m1m1s1ku/e52972ad5fdb6a8817186e67aa85ecbf to your computer and use it in GitHub Desktop.
Save m1m1s1ku/e52972ad5fdb6a8817186e67aa85ecbf to your computer and use it in GitHub Desktop.
Konami RXJS 6
let keyDowns$: Observable<Event | string> = fromEvent(document, 'keyup');
keyDowns$ = keyDowns$.pipe(
map((event: KeyboardEvent) => event.code),
bufferCount(10, 1),
map(codes => codes.join(',')),
filter(codes => codes === "ArrowUp,ArrowUp,ArrowDown,ArrowDown,ArrowLeft,ArrowRight,ArrowLeft,ArrowRight,KeyB,KeyQ")
)
keyDowns$.subscribe(() => {
this.setState({admin: !this.state.admin, item: null});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment