I was making a Flash game that required the “G” keyboard key today. It listens for the KEY_DOWN event, stores that this key is currently down in an array indexed by they G keyCode, and then looks for the same array index when a KEY_UP event occurs.

The problem is, it’s not the same keyCode. Every other key on my keyboard traces the same uint for both KEY_DOWN and KEY_UP, but the G key, traces 71 for key down, and 144 for key up.

Don’t believe me? Try it for yourself. Here’s the code:

this.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, false, 0, true);
this.stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler, false, 0, true);
function keyDownHandler($e:KeyboardEvent):void
{
	trace("\nkeyDownHandler() $e.keyCode:"+$e.keyCode+"");
}
function keyUpHandler($e:KeyboardEvent):void
{
	trace("> keyUpHandler() $e.keyCode:"+$e.keyCode+"");
}

Update 1: Apparently this only happens when compiling in Flash CS5. If you re-run the swf after compiling it in the debug player, 71 is properly traced both times. Still a bug, but not as severe.

Update 2: Valerio Virgillito, a Flash Professional Sr. Quality Engineer for Adobe, has verified that “This is a known issue on Mac. It’s a player bug and has nothing to do with Flash CS5we have an internal bug filed for [it]. Once it’s fixed for the player the changes will trickle down to authplay

I filed a bug report, which you can see and vote for here:
https://bugs.adobe.com/jira/browse/ASL-154