Skip to content

Instantly share code, notes, and snippets.

Created September 26, 2014 16:04
Show Gist options
  • Save anonymous/eab4d44fe6cd3e19116c to your computer and use it in GitHub Desktop.
Save anonymous/eab4d44fe6cd3e19116c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
$(document.activeElement).on('keydown', function(e) {
switch (e.which) {
// key code for left arrow
case 37:
console.log('left arrow key pressed!');
break;
// key code for right arrow
case 39:
console.log('right arrow key pressed!');
break;
}
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-git2.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">$(document.activeElement).on('keydown', function(e) {
switch (e.which) {
// key code for left arrow
case 37:
console.log('left arrow key pressed!');
break;
// key code for right arrow
case 39:
console.log('right arrow key pressed!');
break;
}
});</script></body>
</html>
$(document.activeElement).on('keydown', function(e) {
switch (e.which) {
// key code for left arrow
case 37:
console.log('left arrow key pressed!');
break;
// key code for right arrow
case 39:
console.log('right arrow key pressed!');
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment