C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Capturing the key press event using Javascript (For Both IE and FireFox) Browsers


Posted Date: 23 Jan 2008    Resource Type: Articles    Category: .NET Framework

Posted By: gowri prasad channuru       Member Level: Silver
Rating:     Points: 7



Capture Key press



Here the code below gives ID of the key which is pressed by keyboard.
I had given few keyNames with respective to my key board.It may differ depends on the key board.

call a javascript function, using below statement.

document.onkeyup = KeyCheck; 


To make it work in both Internet and Firefox, use the same function - KeyCheck() - but with an argument this time (e). Also, we use an inline condition so that the appropriate method is used depending on the browser:


function KeyCheck(e)
{
var KeyID = (window.event) ? event.keyCode : e.keyCode;
switch(KeyID) {
case 16: document.Form1.KeyName.value = "Shift"; break; } }


And the ID of the key which is pressed is sent to a textbox(KeyName) on WebForm(form1 ).
U can have as many case as u want based on the keys u want to capture.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Intervie wQuestions - .Net Windows Forms
Previous Resource: Abstract or MustInherit classes in VB.Net
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing

Contact Us    Privacy Policy    Terms Of Use