I have a movie clip with 2 buttons (Ok and Cancel) and one Numeric Stepper.
If the user press enter key on the keyboard I want that "Ok" button function runs and if "BackSpace" is pressed "Cancel" function.
I have this code that detect when I press almost all the keys but not when I press "ENTER" or "BACKSPACE".
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyPressed);
function onKeyPressed(event:KeyboardEvent):void
{
if (event.keyCode==Keyboard.ENTER) {
okBtnFunction();
}
if (event.keyCode==Keyboard.DELETE) {
cancelBtnFunction();
}
}
I also tried with event.charCode.
Enter and Backspace keys aren't enable because of the flash shortcut, you can see it in this link:
Flash AS3: ENTER does not get detected, but CTRL+ENTER works fine
If you try to get keyboard event inside NumericStepper you have to use:
Remember to use textField after numeric stepper name.