Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 90000

Re: Not Getting Key Code for ALT key

$
0
0

Hi Amanpreet,

 

The code i posted was a working example to detect Alt + click. You can try pasting it in the Actions panel of a blank AS3 file, Test Movie, press Alt and Click on the blank area of Stage and see that the trace statement appears in Output panel.

 

Flash does not return the keycode of Alt key directly but lets you detect if Alt was pressed or not using 'event.altKey'. This boolean property is available for both Keyboard and Mouse events.

You can try another sample: (This will only work when you Test Movie on Browser)


//Place a dynamic textbox named 'txtStatus' on stage to display the text.

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);

function keyHandler(e:KeyboardEvent) {

       txtStatus.text = e.keyCode.toString(); 

       if(e.altKey)

            txtStatus.text = 'alt pressed';

}


When you Test Movie in browser, you'll need to click on the Stage area once to set it in focus. Also make sure to embed your fonts or set 'use device fonts' Anti-alias setting to display the text correctly.


-Nipun


Viewing all articles
Browse latest Browse all 90000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>