Skip to content

Instantly share code, notes, and snippets.

@r3b
Created December 11, 2020 17:36
Show Gist options
  • Save r3b/88fabc090abd2178a88570c6ef78e364 to your computer and use it in GitHub Desktop.
Save r3b/88fabc090abd2178a88570c6ef78e364 to your computer and use it in GitHub Desktop.
easter egg
const expected = [
'ArrowUp',
'ArrowDown',
'ArrowUp',
'ArrowDown',
'ArrowLeft',
'ArrowRight',
'ArrowLeft',
'ArrowRight',
'a',
'b',
'a',
'b',
'Enter',
]
fromEvent(document, 'keyup')
.pipe(
map((e: KeyboardEvent) => e.key),
bufferCount(expected.length),
mergeMap(keys =>
from(keys).pipe(
sequenceEqual(from(expected))
)
)
)
.subscribe(e => console.log(`You win!`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment