The relevant event handlers
These events can be binded to most elements on the page, though you'll probably be sticking to either the "document" element or form field elements in most cases, as appealing as having your script react to a keypress on a <h1> element is.
Binding a keyboard event to an element
To bind a keyboard event to an element, you can do so either inside your script, or directly inside the element's tag inside your HTML:
<form> <input type="text" value="Click here, then press a key" onkeypress="alert('You pressed the keyboard inside this field!')" /> </form>
Now that you know how to bind a keyboard event handler to an element, it's time to get to the meat of things- how to detect what key was pressed, and react accordingly in your script!