Skip to content

@tamalw /js_key_example.html
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript key bindings
<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.