Created
October 17, 2016 01:27
-
-
Save shamdasani/981b734ed91a70d0fe840dc0e38236aa 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
// generator function | |
function getColor() { | |
return '#' + Math.random().toString(16).slice(2, 8); | |
} | |
// sets background color style | |
function setBackground() { | |
var bgColor = getColor(); | |
document.body.style.background = bgColor; | |
} | |
// runs function on click | |
document.body.onkeyup = function(e){ | |
if(e.keyCode == 32){ | |
setBackground(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment