Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

JavaScript key bindings

View js_key_example.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<html>
<head>
<title>JS Key Example</title>
<script type="text/javascript">
addEventListener("keydown", function (e) {
var output = document.getElementById('output');
if (e.keyCode == 37) {
output.innerHTML = "You pressed left."
}
if (e.keyCode == 38) {
output.innerHTML = "You pressed up."
}
if (e.keyCode == 39) {
output.innerHTML = "You pressed right."
}
if (e.keyCode == 40) {
output.innerHTML = "You pressed down."
}
}, false);
</script>
</head>
<body>
<h1 id="output"></h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.