I tired to write a function to check key code with javascript. It\'s working fine for firefox but not IE. Does anyone know what is going wrong with my code? Please see below cod
switch your first line of code:
...
var e = e || window.event;
...
and see if that helps.
Also, if it is a unicode character try something like the following:
function displayunicode(e) {
var unicode=e.keyCode? e.keyCode : e.charCode
alert(unicode)
}
If you're handling keydown
instead of keypress
, then things get a bit more complex... See: http://unixpapa.com/js/key.html