Jump to content

Error in Keyup event


maheshforum
 Share

Recommended Posts

Hi, I need to get the keycode of the keys . I'm using the following code to display the keycode. But every time when i press a key It displays undefined.function getKeycodes(e){ var KeyID = (window.event) ? event.keyCode : e.keyCode; var keyID1=this.getValue(); alert(keyID1.keyCode); }Thanks in Advance,Maheshwaran Devaraj

Link to comment
Share on other sites

document.onkeyup = function(e) {	if (!e) e = window.event;	var keycode = e.charCode ? e.charCode : e.keyCode;}

keycode is the unicode value of the key pressed, this function will run every time the user releases a key.

Link to comment
Share on other sites

if you put ids in your html elements you can attach the events with javascript.

document.getElementById("elementID").onkeyup = keyHandler;function keyHandler(e) {	if (!e) e = window.event;	var keycode = e.charCode ? e.charCode : e.keyCode;}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...