R – Detecting alt keyDown keyboard event in Flex

actionscript-3airapache-flexflash

I am trying to detect the key down event for the alt key in flex. I have a standard event listener for KeyboardEvent.KEY_DOWN and KeyboardEvent.KEY_UP but don't get any response for the alt key (or ctrl key).

I know I can detect if the alt key was pressed via a mouse event, but I want to update the cursor when the alt key is pressed to show it will perform a different action from when it's not pressed.

I am using Safari on a Mac for developing so let me know if perhaps it's an isolated issue.

Best Answer

I don't have a Flex environment in front of me, but I don't think the modifier keys (Shift, Control, and Option in your case) signal keyboard events. If I'm right, you could still get most of what you want by testing the state of the control and alt keys on each MouseEvent, and updating the cursor state as appropriate.

It might also work to continuously sample the state of the option keys in the background, but I don't remember how to get the keyboard state without an interface event to work from. Best of luck.

Related Topic