murli2308
murli2308

Reputation: 3002

Cordova "hidekeyboard" event not working in Cordova 5.0

I have added event "hidekeyboard" as follows.

document.addEventListener("hidekeyboard", function () {
        alert("keyboard hidden");
}, false);

This should fire when we hide soft keyboard on mobile device. Normally when we focus input element soft keyboard comes up and it fires "showkeyboard" event. Also when keyboard gets hide "hidekeyboard" event gets fired. It was working before when I was using cordova 4.0 but now I updated the cordova to 5.0 and now it is not working.

Upvotes: 2

Views: 703

Answers (2)

Hardik Vaghani
Hardik Vaghani

Reputation: 2173

document.addEventListener("deviceready",onDeviceReady,false);

function onDeviceReady () {
    document.addEventListener("hidekeyboard", onHide, false);
    document.addEventListener("showkeyboard", onShow, false);

}
function onHide() 
{
    alert("hide");
}

function onShow() 
{
    alert("show");
}

Try adding listeners in Platform ready OR Document ready.

Regards.

Upvotes: -1

Dinesh Belkare
Dinesh Belkare

Reputation: 631

After release of Cordova Android 4.0.0, "hidekeyboard" and "showkeyboard" events were removed.You should use a plugin instead. You can confirm this here (https://cordova.apache.org/announcements/2015/04/15/cordova-android-4.0.0.html) ,take a look at "Other Changes" section. If possible in your case, you can use below script, as "window resize" event gets called when keyboard is shown or hidden.

window.onresize = function(){
  if($('.footer').css('position') == 'fixed')
	$('.footTab').css('position','relative');
  else
	$('.footer').css('position','fixed');
};

Upvotes: 4

Related Questions