Skip to content

Instantly share code, notes, and snippets.

@olivere
Created February 22, 2011 13:46
Show Gist options
  • Save olivere/838674 to your computer and use it in GitHub Desktop.
Save olivere/838674 to your computer and use it in GitHub Desktop.
A test for keyboard events
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Keypress Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(function() {
$(document).keypress(function(e) {
console.dir(e);
$('<li></li>').html(e.which).appendTo($('#keys'));
});
});
</script>
</head>
<body>
<h1>Press any key</h1>
<ul id="keys"></ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment