Going mouse less using keyboard shortcut in Asp.Net

Hi,

 

Many a times when working with the Web Application you would like to give the user the comfort of getting the job done without using the mouse. It can be of great use to the user if they can perform many tasks using the keyboard in a web application. If you have used Gmail you would know how easy it can be to select mails using some key.  This feature can be implemented in Asp.net also very easily.

 

In my example I will talk about how to link a key button with the click event of a button. What we will do is bind the keyboard shortcut to the click event of a button, hence the task will be performed on both keyboard click and mouse click of the button.

 

document.attachEvent('onkeyup', KeysShortcut);

 

// Now we need to implement the KeysShortcut
function KeysShortcut ()

{

     if (event.keyCode == 49)

     {  
       document.getElementById('<%= button1.ClientID %>').click();

     }

}

 

Now when the user click on the key 1 the click event of the button1 will be fired.

 

Vikram


Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Posted on 3/7/2008 6:53:44 AM

Hey Vikram,

This is a great idea. So you could actually do this for any key and underline the letter in the button to mimic the behavior in smart clients. I assume you'd also want to test whether they're holding the alt button as well?

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2008 Vikram Lakhotia