Why does code:
','.charCodeAt(0);
generates 44
even though charcode for comma is 188
(both by this table and when getting event.keyCode
in keyup
handler).
Why does code:
','.charCodeAt(0);
generates 44
even though charcode for comma is 188
(both by this table and when getting event.keyCode
in keyup
handler).
Characters and keys are different things.
charCodeAt
returns the numeric Unicode value of the character.
keyCode
from the KeyboardEvent
represents a key on a keyboard.
Since there is no 1:1 mapping between characters and keys, they don't necessarily use the same values.