WHAT'S NEW?
Loading...

Multi Keyboard Event AS3


import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
var _theyArePressed:Object = {};

stage.addEventListener(KeyboardEvent.KEY_DOWN, onDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onUp);


function onUp(e:KeyboardEvent):void
{
 _theyArePressed[e.keyCode] = false;
}

function onDown(e:KeyboardEvent):void
{
 _theyArePressed[e.keyCode] = true;
 if (_theyArePressed[Keyboard.SPACE] && _theyArePressed[Keyboard.UP])
 {
  trace("ockey");
  //do anything
 }
}