Posted By

chrisaiv on 05/24/11


Tagged

remote keyboard as3


Versions (?)

As3: Detect Remote Control Buttons using Key Codes


 / Published in: ActionScript 3
 

Whenever you press on a remote control button (through wireless), Flash can detect what button is being pressed

  1. stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler);
  2.  
  3. // Key Handling
  4. public function onKeyDownHandler( e:KeyboardEvent ):void
  5. {
  6. trace("Key Down:" + e.charCode + ":" + e.keyCode);
  7.  
  8. switch( e.keyCode )
  9. {
  10. case 16777227: // rev
  11. break;
  12.  
  13. case 16777226: // fwd
  14. break;
  15.  
  16. case 16777223: // play
  17.  
  18. case 13: // ok,enter
  19. break;
  20.  
  21. case 16777225: // stop
  22.  
  23. break;
  24.  
  25. case 16777224: // pause
  26.  
  27. break;
  28.  
  29. case 16777220: // ch+
  30.  
  31. case 38: // up
  32. break;
  33.  
  34. case 16777221: // ch-
  35.  
  36. case 40: // down
  37. break;
  38.  
  39. case 62720: // A - remote
  40.  
  41. case 65: // A - keyb
  42.  
  43. case Keyboard.RIGHT:
  44. break;
  45.  
  46. case Keyboard.LEFT:
  47. break;
  48. }
  49. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: adrianparr on July 29, 2011

Hi chrisaiv, These keyCodes are pretty handy. How did you find out the values for things like play, stop, pause etc? Adrian

Posted By: chrisaiv on September 10, 2011

Hi Adrian,

The hard way. I would press the keys on my remote and look at the trace statements.

You need to login to post a comment.