Home > ASP.Net, jQuery > jQuery KeyDown Event

jQuery KeyDown Event

There will be scenarios which require to capture KeyDown event and execute some business logic. Here is one generic function I uses to accomplish this task.

    function CheckKey(e) {
        var keynum;
        if (window.event) // IE
            keynum = e.keyCode;
        else if (e.which) // Netscape/Firefox/Opera
            keynum = e.which;
        if (keynum == 8) {
           //Example: If backspace clear id


   <input id="txtEmployee" onkeydown="CheckKey(event);" />      
Categories: ASP.Net, jQuery
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: