Skip to content

ebhsgit/cordova-plugin-power-button-listener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
	}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published