Created
February 10, 2016 08:51
-
-
Save jduncanator/f856eb25a109a6a1de1f to your computer and use it in GitHub Desktop.
WhatTheKeyCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>What The Key Code?</title> | |
<meta name="description" content="JavaScript keyCode finder" /> | |
<meta name="keywords" content="JavaScript,keyCode,key,code" /> | |
<style type="text/css"> | |
body { | |
font-weight: 100; | |
font-family: "DINPro", "Museo Sans", "Droid Sans", "Helvetica Neue", sans-serif; | |
background: #f7f5ef | |
} | |
#kc, #m { | |
position: fixed; | |
font-size: 200px; | |
text-align: center; | |
width: 100%; | |
left: 0; | |
height: 200px; | |
line-height: 200px; | |
top: 50%; | |
margin-top: -100px; | |
color: #a89c8d; | |
} | |
#m { font-size: 80px; } | |
a { | |
position: fixed; | |
left: 50%; | |
margin-left: -64px; | |
bottom: 50px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="m">Press a key, any key.</div> | |
<div id="kc"></div> | |
<script> | |
document.onkeydown = document.body.onkeydown = function(e){ | |
e = e || window.event; | |
document.getElementById('m').innerHTML = ''; | |
document.getElementById('kc').innerHTML = e.keyCode || e.which; | |
return false; | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment