I recently tried to mirror some input within input(text) fields.
Using
String.fromCharCode(event.which)
for instance, translates all ‘standard’ characters correctly. Well it translates them all
to uppercase, but that you can easily catch by looking up the shift key aswell.
My Problem is, it can’t translate characters like dots, commas, questionmarks etc.
First guess was that I have to define a character encoding set, but that does not seem to help. Maybe it’m completly off?
Kind Regards
–Andy
I think you are using the
keyuporkeydownevents, in those events you get actually the key what was pressed, not the actual character, e.g. if the user pressesaorA, you will get65as the key code.You should use the
keypressevent in order to know the exact character that was pressed, e.g.:Check a live example here.