onkeyup event



The onkeyup event activates when a keyboard key is released on an element.  The event can be specified as a JavaScript expression or the name of a JavaScript function.  

If an expression is used, the JavaScript keyword this refers to the element on which the key was released.  

If the name of a function is used, the function will receive 2 parameters when called: 

  • The browser event object; this object can be used to retrieve the JavaScript key code for the key released using the keyCode property

  • A reference to the element on which the key was released

Example:

The following code uses AJAX to retrieve a customer's name as the customer number is being typed into an input box.

onkeyup: getCustomerName

// This function will be called on every key stroke // When a valid customer number is typed, the customer name will appear on the screen function getCustomerName(event, element) { var customerNumber = element.value; ajaxJSON({ url: "/cgi/GETCUST.pgm", params: { "CSNUMBER": customerNumber }, method: "post", async: true, handler: function(response) { changeElementValue("CSNAME", response.CSNAME); } }; }