Skip to content

Instantly share code, notes, and snippets.

@bjarneo
Last active November 9, 2015 21:23
Show Gist options
  • Select an option

  • Save bjarneo/fc3f6b286d75117a991e to your computer and use it in GitHub Desktop.

Select an option

Save bjarneo/fc3f6b286d75117a991e to your computer and use it in GitHub Desktop.
(function(){
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
var body = document.querySelector('body');
body.style.backgroundColor = 'white';
body.innerHTML = '';
document.addEventListener('keydown', function changeBackgroundColor() {
body.style.backgroundColor = getRandomColor();
}, false);
}());
@bjarneo
Copy link
Copy Markdown
Author

bjarneo commented Nov 9, 2015

For the kid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment