Skip to content

Instantly share code, notes, and snippets.

@strburst
Last active August 29, 2015 14:21
Show Gist options
  • Save strburst/d6d3786a6e95a763d5b1 to your computer and use it in GitHub Desktop.
Save strburst/d6d3786a6e95a763d5b1 to your computer and use it in GitHub Desktop.
Basic key event test page
$(function() {
$('body').keydown(function(event) {
console.log('keydown event', event.which);
});
$('body').keyup(function(event) {
console.log('keyup event', event.which);
});
$('body').keypress(function(event) {
console.log('keypress event', event.which);
$(this).append(String.fromCharCode(event.which));
});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
<title>Key Test Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="key.js" type="text/javascript"></script>
</head>
<body>
<h1>Key Test Page</h1>
<p>Press anything you want.</p>
<p id="results"></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment