I am currently working with JavaScript on my MacBook Pro running OSX 10.11.x, using the Chrome browser. The function I am using is:
window.onkeypress = function(e) {
var key = e.keyCode ? e.keyCode : e.which;
console.log("keypressed = " + key);
}
When I press the 'a' key on my keyboard, it logs as 97, which is different from the widely accepted keyCode of 65 found on the internet.
This discrepancy extends to other keys as well. For example, 's' logs as 115 for me, while it is commonly known to have a keyCode of 83.
Could there be a missing dependency causing this inconsistency? If I assume that a == 95 and fire an event, will it work on other browsers as well?
Thank you.