Simulating a button press

Is there a way to simulate a specific button press such as ESC.  Im developing for android and using cordova i'm able to tie into the hardware buttons and I'd like to tie in the back button on the device to act like the esc button on the keyboard.


I can fire a common event on a back button but that's not doing what i want it to do.  The touch interface is kinda wonky and id like to make it better.  I've looked over yanfly's picture common events plugin to try and see how someone else would do it, but even that's not working in android.


Here's a code snippet of my plugin:

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

  function onDeviceReady() {
      document.addEventListener("backbutton", onBackKeyDown, false);
	  document.addEventListener("volumeupbutton", onVolumeKeyDown, false);
	  document.addEventListener("volumedownbutton", onVolumeKeyUp, false);
  }

  function onBackKeyDown() {
      if(!Utils.isMobileDevice) return false;
   //   $gameTemp.reserveCommonEvent(BackEvent); this line works - it will call the common event like clockwork   
	  var button = 'escape';
	  Input._latestButton = button;
      Input._pressedTime = 0;
   }

Original thread: https://forums.rpgmakerweb.com/threads/simulating-a-button-press.61346/