Just thinking out loud, but I took a look at the code and I am wondering if this would this not be better implemented as a singleton?

On 11/15/2010 6:01 PM, Glen Pike wrote:
Hi,

I would suggest using a "keyboard manager" class that tracks when various keys are pressed and sets a flag - this would effectively allow you to "Poll" such keys when you are checking others.

There is a good example from Richard Lord here:

http://www.richardlord.net/blog/polling-the-keyboard-in-actionscript-3

HTH

Glen

On 15/11/2010 22:43, Benny wrote:
In an application I am building I need to detect whether the (right) alt-key
was pressed in combination with another (letter) and make sure that the
control key isn't being pressed at the same time.

But it looks like the Keyboard events for both MOUSE_DOWN and MOUSE_UP
always return true for ctrlKey (when it is not actual pressed!) while the
Alt key is pressed.

Simplified test code:

import flash.events.KeyboardEvent;

stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpHandler);

function onKeyDownHandler(e:KeyboardEvent):void
{
    trace("onKeyDown: e.ctrlKey=" + e.ctrlKey + ", e.altKey=" +
e.altKey);
}

function onKeyUpHandler(e:KeyboardEvent):void
{
    trace("onKeyUp: e.ctrlKey=" + e.ctrlKey + ", e.altKey=" + e.altKey);

}

When I test the code (tested on 2 PC's with Flash 10 or 10.1 Debug player in
Flash pro CS5 or via same version debug players in MSIE/FF browsers) and
press only the right alt key or a key combi e.g. right-alt-5 the traces
report always true for the ctrlKey, so even when it isn't pressed!?

I checked the Adobe bug base, tried Google, but didn't find anything related
so far.

What am I missing?

Thanks.

- Benny

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to