Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created January 11, 2011 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/773948 to your computer and use it in GitHub Desktop.
Save walterdavis/773948 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6/prototype.js"></script>
<script type="text/javascript" charset="utf-8">
// <![CDATA[
document.observe('dom:loaded',function(){
document.observe('keypress', function(evt){
var code;
if (evt.keyCode) code = evt.keyCode;
else if (evt.which) code = evt.which;
var character = String.fromCharCode(code);
$('message').update('Code was ' + code + ', Character was ' + character);
});
});
// ]]>
</script>
<title>KeyCode Translator</title>
</head>
<body>
<div id="message">
Press any key to continue...
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment