0

I am having some trouble in getting key code for alt key. Can Anyone help in it. I am sharing for source code the way I am trying to do it.

import flash.events.KeyboardEvent;

stage.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent){
  trace("Key== "+e.keyCode); 
  txt.text=""+e.keyCode;
});
Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146

1 Answers1

1

There is no key code for alt key. Instead, your should use KeyboardEvent#altKey getter, to check is alt key down or not.

stage.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent){
    if (e.altKey)
    {
        trace("Alt key is down");
    }
});
ChessMax
  • 2,125
  • 1
  • 16
  • 16
  • I have tried this one as well. But it is working with browser only. I want to get ALT key in .swf file, without any browser. I am gonna publish flash.exe file. – user3851812 Jul 18 '14 at 11:50