Created
February 10, 2018 10:10
-
-
Save m1m1s1ku/3f8f0fd11ba5ce5742a8350dddb218cf to your computer and use it in GitHub Desktop.
Konami code using rx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rx.Observable.fromEvent(document.body, 'keyup') | |
.map((event) => event.keyCode) | |
.bufferCount(7) | |
.subscribe((buffer) => { | |
const keymap = [ 77,73,82,65,78,68,65 ]; | |
const cond = buffer.every((v,i)=> v === keymap[i]) | |
if(cond){ | |
const dialog = this.shadowRoot.querySelector('#debug'); | |
dialog.open(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment