Last active
September 8, 2021 03:45
-
-
Save joe-sharp/e249cbc5cc6576308e519554d08bfb8a to your computer and use it in GitHub Desktop.
Easter Egg on Personal Website
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 keyboard_pic = document.querySelector('div#home-card img') | |
const keyCode = "ASDFU" | |
let keyStack = "" | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function rgbKeyboard() { | |
keyboard_pic.src = "images/keyboard-lit.jpg" | |
for(i = 0; i < 3600; i++) { | |
keyboard_pic.style = `filter: hue-rotate(${i}deg)`; | |
await sleep(10); | |
} | |
keyboard_pic.src = "images/keyboard.jpg" | |
} | |
document.querySelector('body').onkeydown = (e) => { | |
keyStack += e.code.substring(3, 4) | |
if (keyStack.length === 5 && keyStack === keyCode) { | |
rgbKeyboard() | |
keyStack = "" | |
} else if (keyStack.length < 5 && keyStack !== keyCode.substring(0, keyStack.length)) { | |
keyStack = "" | |
} else if (keyStack.length > 5) { | |
keyStack = "" | |
}; | |
} |
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
<div class="card border-primary" id="home-card"> | |
<img src="images/keyboard.jpg" class="card-img-top"> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment