Cordova plugin which notifies when the user presses the power button on the device. It achieves this by inferring from Android screen on and off event.
When the power button is inferred, the plugin fires an window event:
- powerButtonListener
cordova plugin add https://github.com/8bhsolutions/cordova-plugin-power-button-listener.gitcordova plugin remove 8bhsolutions-cordova-plugin-power-button-listener- keyCode: KeyEvent.Power or 'unknown'
- keyAction: Intent.action
- platform: 'android'
Applications have to use window.addEventListenerto attach this event listener once the devicereadyevent fires.
- Android
window.addEventListener("powerbuttonlistener", (info) => { this.onEvent(info); }, false);
function onEvent(info){
console.log("Action: " + info.keyAction);
}