event.keyCode returns the value of comma (188) for Turkish character "ö"
If you want to get the ASCII code you have to listen to the keypress
event and use event.charCode
.
The keydown
event does not provide the charCode
since there is a little difference between these two event types:
In theory, the keydown and keyup events represent keys being pressed or released, while the keypress event represents a character being typed. The implementation of the theory is not same in all browsers.
You should use event.originalEvent.keyIdentifier
method. "ö" and comma has different keyIdentifiers.
Here is a good answer for these kind of problems.I see two rules here:
- to detect a character typed reliably, use keypress (with charCode)
- to detect non-printable characters such as arrows, use keydown (with keyCode)