Last active
December 26, 2015 22:59
-
-
Save Partysun/7227621 to your computer and use it in GitHub Desktop.
Detect the button on android, windows, linux, neco. OpenFL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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