___
07-14-2006, 03:03 PM
I am trying to show a key typed next to its ascii code like this:
function f()
{alert(event.keyCode.toString()+','+String.fromCharCode(event.keyCode))}
It gets called like <input name="a" type="text" onKeyUp="f();">
Digits from the top of the keyboard work like I expect but other characters do not. Here are some examples.
1) type in b and the alert box says 66,B insead of 98,b
2) type in - and the alert box says 189,1/2 instead of 45,-
3) type in . and the alert box says 190,3/4 instead of 46,.
What am I doing wrong?
function f()
{alert(event.keyCode.toString()+','+String.fromCharCode(event.keyCode))}
It gets called like <input name="a" type="text" onKeyUp="f();">
Digits from the top of the keyboard work like I expect but other characters do not. Here are some examples.
1) type in b and the alert box says 66,B insead of 98,b
2) type in - and the alert box says 189,1/2 instead of 45,-
3) type in . and the alert box says 190,3/4 instead of 46,.
What am I doing wrong?