Posted By

sidneydekoning on 10/29/10


Tagged


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

sexyflash
donaldleegraham
ovakimyan
thastyle
jondiscipulo


Accessing System keys in AIR for Android


 / Published in: ActionScript 3
 

As an added bonus you also have access to the keys on your device. Most devices have an HOME, MENU and SEARCH button on the device itself. Of course you can access them. Add an normal key down listener to the stage and respond to it.

  1. stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
  2.  
  3.  
  4. private function onKeyDown(event:KeyboardEvent):void
  5. {
  6. if (event.keyCode == Keyboard.BACK) {
  7. event.preventDefault();
  8. log.appendText("Back Pressed\n");
  9. }
  10. else if (event.keyCode == Keyboard.MENU) {
  11. event.preventDefault();
  12. log.appendText("Menu Pressed\n");
  13. }
  14. else if (event.keyCode == Keyboard.SEARCH) {
  15. event.preventDefault();
  16. log.appendText("Search Pressed\n");
  17. }
  18. }

Report this snippet  

You need to login to post a comment.