Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 976 Bytes

File metadata and controls

41 lines (27 loc) · 976 Bytes

Power-Button-Listener

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

Installation

cordova plugin add https://github.com/8bhsolutions/cordova-plugin-power-button-listener.git

Remove

cordova plugin remove 8bhsolutions-cordova-plugin-power-button-listener

Returned object

  • keyCode: KeyEvent.Power or 'unknown'
  • keyAction: Intent.action
  • platform: 'android'

Applications have to use window.addEventListenerto attach this event listener once the devicereadyevent fires.

Supported Platforms

  • Android

Example

	window.addEventListener("powerbuttonlistener", (info) => { this.onEvent(info); }, false);
	
	function onEvent(info){
		console.log("Action: " + info.keyAction);
	}