PDA

View Full Version : keyboard events



GrndMasterFlash
July 27th, 2007, 01:51 PM
when you do a

function press1(event:KeyboardEvent) {

how do you specify what key to hit?

GrndMasterFlash
July 27th, 2007, 04:19 PM
well this my second thread i posted and answered myself, (is that a bad thing or a good thing?), but for us AS3 nobs (witch is pretty much every one since AS3 is new its self), here is simple key board detection

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

function keydet(event:KeyboardEvent) {
switch (event.keyCode) {
case 49 :
trace("you just pressed 1, or ascii 49");
break;

}
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, keydet);

cheers ma8s:kommie: