Created
April 5, 2018 08:27
-
-
Save leomastoras/19a7d6b4bfb3922aaade9ee4bc7f288a to your computer and use it in GitHub Desktop.
This file contains 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
const keySequence = ['l','o','l']; | |
let userInput = new Array( keySequence.length ); | |
window.addEventListener( 'keydown', ( { key } ) => { | |
userInput = [ ...userInput.slice( 1 ), key ]; | |
if ( keySequence.every( ( v, k ) => v === userInput[ k ] ) ) { | |
alert( 'Yatta!' ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment