PDA

View Full Version : Why "if (Key.isDown(Key.ENTER))" is not working



Knorcedger
October 23rd, 2005, 08:17 PM
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.LEFT)) {
trace("test");
}
};
Key.addListener(keyListener);

The above code works perfect, but if i write ENTER instead of LEFT, it doesnt work, does anybody has any idea of whats going wrong?

Thanx

expensive_pen
October 23rd, 2005, 08:25 PM
hmm that is weird
try using ascii values instead, and then see what happens

Krilnon
October 23rd, 2005, 08:25 PM
That's because you're using the Flash test environment, and the Enter key is the shortcut for 'Play'. While testing, click the 'Control' menu option and check off 'Disable Keyboard Shortcuts'.

Knorcedger
October 23rd, 2005, 08:46 PM
Thank u both guys.

I tried ascii values.
Krilion was right. A standalone swf worked perfectly

expensive_pen
October 23rd, 2005, 08:52 PM
that is very interesting... thanks Krilnon