Eugene M
Eugene M

Reputation: 48965

Is there anyway in flex to poll the keyboard?

I'd like to tell if a certain key is being held down around the startup of my AIR (desktop) application, and I'd like to tell if a specific key (ALT in this case) is being held down. Unfortunately, flex seems to be so event based that there is no way poll the keyboard directly. Can anyone verify this?

I know that it's possible to take the keyboard events and keep track manually. However, this won't work if the user presses the key right before startup, so it isn't a solution for my specific problem.

Upvotes: 1

Views: 145

Answers (2)

Stan Reshetnyk
Stan Reshetnyk

Reputation: 2036

In my app I track ctrl pressed via listening stage MOUSE_MOVE, MOUSE_DOWN and KEY_DOWN. MouseEvent has ctrlKey and altKey properties. I store state in some static variable . When I longer need this I unsubscribe from these events.

Upvotes: 1

Amy Blankenship
Amy Blankenship

Reputation: 6961

If you listen for key up, then you should hear this if the key was down. So you won't actually know right at startup, but when they release the key. You can unsubscribe from that event at some point that you determine is "after startup."

Upvotes: 0

Related Questions