How to detect if the delete key was pressed in Actionscript 3?
actionscript-3, events, flash-cs4, keyboard
Solution
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
....
function onKeyPressed(event:KeyboardEvent):void
{
if (event.keyCode==Keyboard.DELETE) {
.....
}
}
it's workin nice... But if you test movie from Flash, it will not work, so export to swf and test....
Problem
How do I determine if the delete key was pressed using actionscript? ``` addEventListener(KeyboardEvent.KEY_UP, onKeyUp); ... function onKeyUp(event:KeyboardEvent):void { trace(event.keyCode); } ``` The above code yields no value when delete, backspace, enter, and other command keys are pressed. However, arrow keys do yield values.