SHARE
TWEET

isKeyDown

ulfben Oct 30th, 2015 (edited) 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private var _hash:Object = {};
  2.  
  3. private function onKeyReleased(event:KeyboardEvent):void {
  4.     delete _hash[event.keyCode];
  5. }
  6.  
  7. private function onKeyPressed(event:KeyboardEvent):void {
  8.     _hash[event.keyCode] = 1;
  9. }
  10.  
  11. private function isKeyDown(code:int):Boolean {
  12.     return _hash[code] !== undefined;
  13. }
  14.  
  15. stage.addEventListener(KeyboardEvent.KEY_UP, onKeyReleased);
  16. stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
RAW Paste Data
Top