Skip to content

Instantly share code, notes, and snippets.

@vireshas
Created August 23, 2017 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vireshas/7cf462cf8129de3f4c3afb110085d730 to your computer and use it in GitHub Desktop.
Save vireshas/7cf462cf8129de3f4c3afb110085d730 to your computer and use it in GitHub Desktop.
palette example
<!DOCTYPE html>
<html>
<head>
<script>
var map = {};
var toggle = true;
keyEvent = function(e) {
map[e.keyCode] = e.type == 'keydown';
if(map[17] && map[65]) {
img = document.getElementById("image");
if(toggle){
img.style.display = "none";
toggle = false;
} else {
img.style.display = "block";
toggle = true;
}
}
}
document.addEventListener('keyup', keyEvent)
document.addEventListener('keydown', keyEvent)
</script>
</head>
<body>
<img src="globe.jpg" alt="globe" id="image"/>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment