Window.cordova && window.cordova.plugins not Firing

Hi, I have a problem in my app where this code is not firing everytime I run the app on the device:

if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { console.log('cordova available'); }

What seems to be the problem. By the way I already include the cordova.js on my index.html

<script src="cordova.js"></script>

Thanks in advance

Try wrapping them on deviceready

example:

document.addEventListener("deviceready", function(){
  if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
console.log('cordova available');
}
});