jQuery website jQuery documentation

Events / Keyboard

keydown(Function fn) : jQuery

fnFunctionA function to bind to the keydown event on each of the matched elements.

Bind a function to the keydown event of each matched element.

Example

Before
<p>Hello</p>
Code
$("p").keydown( function() { alert("Hello"); } );
Result
<p onkeydown="alert('Hello');">Hello</p>

keydown() : jQuery

Trigger the keydown event of each matched element. This causes all of the functions that have been bound to thet keydown event to be executed.

Example

Before
<p onkeydown="alert('Hello');">Hello</p>
Code
$("p").keydown();
Result
alert('Hello');

onekeydown(Function fn) : jQuery

fnFunctionA function to bind to the keydown event on each of the matched elements.

Bind a function to the keydown event of each matched element, which will only be executed once. Unlike a call to the normal .keydown() method, calling .onekeydown() causes the bound function to be only executed the first time it is triggered, and never again (unless it is re-bound).

Example

Before
<p onkeydown="alert('Hello');">Hello</p>
Code
$("p").onekeydown( function() { alert("Hello"); } );
Result
alert('Hello'); // Only executed for the first keydown

unkeydown(Function fn) : jQuery

fnFunctionA function to unbind from the keydown event on each of the matched elements.

Removes a bound keydown event from each of the matched elements. You must pass the identical function that was used in the original bind method.

Example

Before
<p onkeydown="myFunction">Hello</p>
Code
$("p").unkeydown( myFunction );
Result
<p>Hello</p>

unkeydown() : jQuery

Removes all bound keydown events from each of the matched elements.

Example

Before
<p onkeydown="alert('Hello');">Hello</p>
Code
$("p").unkeydown();
Result
<p>Hello</p>

keypress(Function fn) : jQuery

fnFunctionA function to bind to the keypress event on each of the matched elements.

Bind a function to the keypress event of each matched element.

Example

Before
<p>Hello</p>
Code
$("p").keypress( function() { alert("Hello"); } );
Result
<p onkeypress="alert('Hello');">Hello</p>

keypress() : jQuery

Trigger the keypress event of each matched element. This causes all of the functions that have been bound to thet keypress event to be executed.

Example

Before
<p onkeypress="alert('Hello');">Hello</p>
Code
$("p").keypress();
Result
alert('Hello');

onekeypress(Function fn) : jQuery

fnFunctionA function to bind to the keypress event on each of the matched elements.

Bind a function to the keypress event of each matched element, which will only be executed once. Unlike a call to the normal .keypress() method, calling .onekeypress() causes the bound function to be only executed the first time it is triggered, and never again (unless it is re-bound).

Example

Before
<p onkeypress="alert('Hello');">Hello</p>
Code
$("p").onekeypress( function() { alert("Hello"); } );
Result
alert('Hello'); // Only executed for the first keypress

unkeypress(Function fn) : jQuery

fnFunctionA function to unbind from the keypress event on each of the matched elements.

Removes a bound keypress event from each of the matched elements. You must pass the identical function that was used in the original bind method.

Example

Before
<p onkeypress="myFunction">Hello</p>
Code
$("p").unkeypress( myFunction );
Result
<p>Hello</p>

unkeypress() : jQuery

Removes all bound keypress events from each of the matched elements.

Example

Before
<p onkeypress="alert('Hello');">Hello</p>
Code
$("p").unkeypress();
Result
<p>Hello</p>

keyup(Function fn) : jQuery

fnFunctionA function to bind to the keyup event on each of the matched elements.

Bind a function to the keyup event of each matched element.

Example

Before
<p>Hello</p>
Code
$("p").keyup( function() { alert("Hello"); } );
Result
<p onkeyup="alert('Hello');">Hello</p>

keyup() : jQuery

Trigger the keyup event of each matched element. This causes all of the functions that have been bound to thet keyup event to be executed.

Example

Before
<p onkeyup="alert('Hello');">Hello</p>
Code
$("p").keyup();
Result
alert('Hello');

onekeyup(Function fn) : jQuery

fnFunctionA function to bind to the keyup event on each of the matched elements.

Bind a function to the keyup event of each matched element, which will only be executed once. Unlike a call to the normal .keyup() method, calling .onekeyup() causes the bound function to be only executed the first time it is triggered, and never again (unless it is re-bound).

Example

Before
<p onkeyup="alert('Hello');">Hello</p>
Code
$("p").onekeyup( function() { alert("Hello"); } );
Result
alert('Hello'); // Only executed for the first keyup

unkeyup(Function fn) : jQuery

fnFunctionA function to unbind from the keyup event on each of the matched elements.

Removes a bound keyup event from each of the matched elements. You must pass the identical function that was used in the original bind method.

Example

Before
<p onkeyup="myFunction">Hello</p>
Code
$("p").unkeyup( myFunction );
Result
<p>Hello</p>

unkeyup() : jQuery

Removes all bound keyup events from each of the matched elements.

Example

Before
<p onkeyup="alert('Hello');">Hello</p>
Code
$("p").unkeyup();
Result
<p>Hello</p>