I wrote a segment of code hoping to get key codes when the arrow keys are pressed.
document.onkeypress = function(e) {
var keyCode = 0;
e = e || window.event;
keyCode = e.keyCode || e.which || e.charCode;
console.log(keyCode);
};
I can get my key code in Firefox, but not in Chrome.
The keys is shown below in red box.
How can I get my arrow key code?
Thanks.