In IE9, for keyup event When I use the enter key "event" is not getting, for other keys Iam getting keycode values

When I use Enter key, alert("kcode=="+e.which) the kcode is getting undefined and the if condition is not executed in IE9.

In HTML

<input type="text" id="test"/>

In JS

$(document).ready(function(){
    $("#test").keyup(function(e){

        var kcode = e.which || e.keyCode;
       alert("kcode=="+e.which);
        if (kcode == 13){
            alert("in if");
        }

    });
})

Answers


It seems that IE has some special keys for which it doesn't trigger 'keyup' when pressed. I found this behavior on IE11 for 'keyup'. Instead, I used 'keypress' and worked fine. I also found other internet posts refering similar situations with IE and other key events. this is one of them Hope this helps someone to survive IE issues :)


Probably you need to use window.event in IE. You can try this fiddle I've setup:

http://jsfiddle.net/ytphedvg/

I've tested it in IE9, it works perfectly.

JS

$(document).ready(function(){
    $("#test").keyup(function(e){
        var ev = e || window.event;
        var kcode = ev.which || ev.keyCode;
        alert("kcode=="+ev.which);
        if (kcode == 13){
            alert("in if");
        }
    });
});

Need Your Help

Android Oauth Exception with SMTP Transport connect,with android version 2.3

android oauth gmail oauth-2.0

I am getting following error when I try to run my android project after adding new AUTH XOAUTH2 command.I am using android device with os version 2.3 but same code is working fine on android 4.0

Visual Studio Setup & Deployment: Adding Pre Requisits

visual-studio visual-studio-2008 setup-deployment prerequisites

How can I add into Setup &amp; Deployment project that I want to the client has more components, like: