ASCII unicode values

Giganews Newsgroups
Subject: ASCII unicode values
Posted by:  Jonas_Thörnvall
Date: Thu, 26 Nov 2020

Why does not javascript follow the OS and language implementation of its reflection on keypresses, why does it use some internal "charcode?" set where your keypresses do not follow the way you use them?

key = e.keyCode ? e.keyCode : e.which;
character= String.fromCharCode(key);

In 99.999% of programming cases people probably want the mapping to be done just how the keyboard usually work within OS?

And if i as programmer can do the mapping, why is it not an option to chose  "a natural" mapping, that actually reflect "how the OS" does it?

Every project that use keyboard input have to write the same/similar mapping code? Isn't that rather ridiculous?

Use the OS ,mapping seem to me to be less job to implement, then the awkward way it is implemented now?

Replies