I’m trying to understand the keyboard listeners and make something that will bring up a dialogue box whenever someone types a specific phrase. This is my code:
package {
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
//
public class KeyLogger {
private var keys:String = "";
private var phrase:String = "pass";
public function KeyLogger(stage:Stage):void {
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyReleased);
}
//
private function keyReleased(e:KeyboardEvent):void {
keys += String.fromCharCode(e.keyCode);
if (keys == phrase) {
showBox();
}
trace(keys);
}
//
private function showBox():void {
//
}
}
}
The weird thing is the listener seems to be capturing key presses, but not all of them. I tried every letter a-z then the numbers on the keyboard and it only grabbed these:
DGUWX1234567890
Is there something I’m unaware of about these keys that would cause this?