Skip to content

Instantly share code, notes, and snippets.

@Partysun
Last active December 26, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Partysun/7227621 to your computer and use it in GitHub Desktop.
Save Partysun/7227621 to your computer and use it in GitHub Desktop.
Detect the button on android, windows, linux, neco. OpenFL
import flash.ui.Keyboard;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.Lib;
public function new()
{
super();
#if (cpp || neko)
Lib.current.stage.addEventListener (KeyboardEvent.KEY_UP, stage_onKeyUp);
#end
}
#if (cpp || neko)
private function stage_onKeyUp (event:KeyboardEvent):Void
{
if (event.keyCode == Keyboard.ESCAPE //Keyboard.BACK) {
event.stopImmediatePropagation();
//Your code here
}
}
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment