1
votes

I am looking for a solution in Flex where I can capture a combination of keyboard inputs such as: [CTRL] + A + B

That is, pressing the CTRL key and the user presses two keys (instead of the usual one).

I can capture the event when somebody keys: [CTRL] + A with the following code:

if (event.ctrlKey && event.keyCode == 65)

How would I capture an additional key so that the event is captured when somebody presses CTRL, A and B?

1

1 Answers

0
votes

You will need to listen to KEY_DOWN as well as KEY_UP, and use these to set an internal flag denoting whether A or B is currently pressed. - let's call it a_isDown:boolean and b_isDown:boolean.

Then, in your KEY_DOWN event,

if (event.ctrlKey && ((event.keyCode == 65 && b_isDown) || 
   (event.keyCode == 66 && a_isDown))) { ... }