Capturing a value of a Key Press

Capturing the value of  keyboard each keys can done using Javascript. Here we can implement the Key Press event in the input box. we can find the value using the following function.

<input type=”text” name=”keyVal” id=”keyVal” keypress=”keyDown(event)” />

function keyDown(e)
{
 dKey=(bw.ns)?e.which:event.keyCode;
// ie not case sensitive ?
dLet=String.fromCharCode(dKey);
dValues=”dKey=” + dKey+” dLet=” + dLet; alert(dValues);
}

The above function get invoked on each key press on the input box on the browser.

 

Advertisements

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: