Graphics Reference
In-Depth Information
There's more...
In this recipe, we only showed the key code values for the arrows. There is, of
course, a separate key code for each key on your keyboard. A good explanation of
how the various keys are mapped (especially, the special ones such as the function
keys) can be found at http://unixpapa.com/js/key.html . If you want to know the key
value of a specific key, and you don't feel like looking up the value in a list, you can
also use just the following simple handler to output the key codes to the JavaScript
console:
function setupKeyLogger() {
document.onkeydown = function(e) {
console.log(e);
}
}
This small handler logs the complete event. In the output to the console, you can
then see the key code that is used, as shown in the following screenshot:
Search WWH ::




Custom Search