Re: What's wrong with keyCode and String.fromCharCode




Pugi! wrote:
It is example of adding an eventlistener to a textarea. The events works
alright, but when I press 'a' the alert gives me 'A', when I press '8' I get
'h', when I press '0' I get ''', when I press 'à' I get '0', ....
Has probably something to do with the fact that I don't live in the UK or
USA. But it shouldn't matter; a key is a key.

No it's not ;-) Do not mix keyboard *scancodes* with *keycode*.
Scancode is the system value assigned to each key on your keyboard.
This value is indead layout-independent. Keycode is Unicode value going
to receiver: it depends on current layout, shift state etc.

In your particular case though it may help to monitor 'okeypress'
instead of 'onkeydown' as you're doing right now.

.