Search within TutorialsPark

Jquery Keyboard and Browser Events


Learn to use jQuery events that are triggered by Keyboard and Browser Event


jQuery Events: Browser Events

jQuery has a set of methods to use and handle browser related events.

Table : Mouse Event Methods

Method Description
error(function) To bind function to be called when the element receives an error event(browser-dependent).
resize(function) To bind handler to be called when the element is resized
scroll(function) To bind function to be called when the element's scroll positon changes.

jQuery Browser Events : Using the error() Method

The jQuery method of error() corresponds to the error event, it is triggered when there is error, eg: problem loading an external resource.

Example: Using the error() Method

Give it a TRY! » Note: The parameter within the function is executed each time the event is triggered.


jQuery Browser Event: Using the resize() Method

A jQuery method of resize(function) corresponds to resize event, it is triggered when the browser window is resized.

Example: Using the resize() Method

Give it a TRY! » Note: The parameter is function that is executed each time the event is triggered.


jQuery Browser Events : Using the scroll() Method

The jQuery method of scroll() corresponds to the scroll event, it is triggered when the scrollbars are used.

Example: Using the scroll() Method

Give it a TRY! » Note: It returns a jQuery object which can be used for chaining purposes.


jQuery Events: Keyboard Events

Table : Keyboard Event Methods

Method Description
keydown(function) To bind function to be called when a key is pressed and the element has keyboard focus.
keypress(function) To bind handler to be called when a keystroke occurs and the element has keyboard focus.
keyup(function) To to be called when a key is released and the element has keyboard focus.

jQuery Events: keydown() Method

The jQuery method of keydown() corresponds to keydown event, it is triggered when the user presses a key.

Example: Using the keydown() Method

Give it a TRY! » Note:The parameter is a function that is execute each time the event in triggered.


jQuery Keyboard Events : Using the keypress() Method

The jQuery method keypress() is triggered when the user presses and releases a key.

Example: Using the keypress() Method

Give it a TRY! » Note:The parameter is a function that is execute each time the event in triggered.


jQuery Keypress Events : Using the keyup() Method

The jQuery method of keyup() corresponds the keyup event, it is triggered when the user releases an key.

Example: Using the keyup() Method

Give it a TRY! » Note:The parameter is a function that is execute each time the event in triggered.