Skip to content

Instantly share code, notes, and snippets.

@Ch00k
Created December 17, 2015 10:16
Show Gist options
  • Save Ch00k/bc44aa9a824a153b5e64 to your computer and use it in GitHub Desktop.
Save Ch00k/bc44aa9a824a153b5e64 to your computer and use it in GitHub Desktop.
App
<html>
<head>
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
}
div {
width: 16px;
height: 16px;
float: left;
}
.white {
background: #ffffff;
}
.black {
background: #000000;
}
</style>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(document).keydown(function(e){
console.log(e.which)
switch(e.which) {
case 37: // left
$('#screen').removeClass('white').addClass('black');
break;
case 39: // right
$('#screen').removeClass('black').addClass('white');
break;
default: return; // exit this handler for other keys
}
e.preventDefault();
});
</script>
</head>
<body>
<div id="screen" class="white"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment