View Full Version : Detecting the key teh user pressed...

Code Wizard
12-30-2003, 02:47 PM
Ok...so the event.keyCode property returns the Unicode of the key pressed,also this property has a value only when the user presses a button otherwise it'll be undefined.
To return the pressed key I(and most I guess...) use:
function getKey()

Now,the problem is I can't detect the backspace and arrow(cursor) keys....but yet some sites look like doing this....so how is it done then??

Willy Duitt
12-30-2003, 03:19 PM
You must use onkeyup as opposed to onkeypress to cature some event.keys. This link (http://www.w3.org/2002/09/tests/keys.html) may help.


Code Wizard
12-31-2003, 02:30 PM
I knew that some event props were useful only for some specific event handlers.

Mr J
12-31-2003, 08:52 PM
You may have to use onkeydown as this may give a different result to onkeypress

See here for more info