Answered
Detecting a Key Press
I am using this code to set up a listener for a key press. I
noticed that it works fine when you use a LEFT, RIGHT etc. press,
but it will not work with a regular key press(i.e. ctrl+P). It says
that there is an undefined property as far as the Letter goes. If
anyone can help me with this, I would very much appreciate it.
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
function keyDown(event:KeyboardEvent):void
{
if(event.ctrlKey)
{
var key = event.keyCode;
var P_key = Keyboard.P;
switch(key)
{
case P_key:
trace("this thing works");
break;
}
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
function keyDown(event:KeyboardEvent):void
{
if(event.ctrlKey)
{
var key = event.keyCode;
var P_key = Keyboard.P;
switch(key)
{
case P_key:
trace("this thing works");
break;
}
}
}