KeyPress event of HTML page
-
I have a HTML page with a Input tag, I want to capture KeyPress event to get code of the pressed key ( ex : alphabe key, numberic key, ...). I'm in dark. Please help me, thanks.
Hi, I just solved problem like yours. Try following function keydown() { if(window.event.keyCode==13) { //logic of key pressed - it returns ascii code // this will run everytime when any key is pressed on a webform. } } ... .. ... Hope this will solve your problem. Atul. -- modified at 1:56 Friday 7th October, 2005
-
I have a HTML page with a Input tag, I want to capture KeyPress event to get code of the pressed key ( ex : alphabe key, numberic key, ...). I'm in dark. Please help me, thanks.
you can add onKeyPress function to any textbox, textarea, list box or even to the page in body tag. write a javascript function e.g: function getkeypressed() { alert('Key code: '+ event.keyCode) } and call the above function whereever u want onkeyPress of body, textbox etc. Salim Akbar -- modified at 12:11 Friday 7th October, 2005
-
Hi, I just solved problem like yours. Try following function keydown() { if(window.event.keyCode==13) { //logic of key pressed - it returns ascii code // this will run everytime when any key is pressed on a webform. } } ... .. ... Hope this will solve your problem. Atul. -- modified at 1:56 Friday 7th October, 2005