jQuery provides three event functions that allow the jQuery developer to determine what key a user is pressing, and when and how the user is pressing it. The .keyup()
function is an event handler that can be attached to an input and will be fired once the pressed key has been fully released; likewise, .keydown()
will be fired once the key has been fully pressed. The third available event handler is .keypress()
, which is fired instantly when a key is pressed.
These methods allow the developer to provide powerful client-side validation or to provide the user with simple features such as triggering a form submission when the Enter key is pressed.