eventKeyboardEvent Object

An object that contains information about the keyboard event, such as the key that was pressed. The properties available to you in this object are defined and set by the client's browser.


Specify the Javascript for this event. The onKeyDown event fires when the user presses a Key down and the element has focus.


The onKeyDown event fires when the user presses down a key on the keyboard when an element has focus. It is the first keyboard event to fire when the user presses a key. This event can be used to execute an Action Javascript, custom JavaScript, or server-side Xbasic to perform an action. For example, when filling out a text control, you may want to trigger the click event for a button (such as a login button) when the user hits the Enter key.

// Submit the UX if the Enter Key has been pressed
if (event.keyCode == 13) {
   // Enter key has been pressed

   // Simulate clicking the SUBMIT button:

For more information about keyboard events, see Mozilla's documentation on KeyboardEvents or the developer documentation for your favorite web browser.

See Also