Skip to content

Instantly share code, notes, and snippets.

@pluswave
Created August 1, 2014 10:36
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 pluswave/606f1002dcca6fdc5f00 to your computer and use it in GitHub Desktop.
Save pluswave/606f1002dcca6fdc5f00 to your computer and use it in GitHub Desktop.
not work on chromium, but works on firefox (however, keyCode is wrong)
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DocumentKeyTest</title>
<script>
function load(){
var body = document.getElementById("body")
body.addEventListener("keypress", keypress);
function keypress(e)
{
document.getElementById("p1").innerHTML = "key press " + e.keyCode;
}
}
</script>
</head>
<body id="body" onload="load()" >
<h1>DocumentKeyTest</h1>
<div id="p1">
</div>
<div id="p2">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment