Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-20-2003, 07:07 AM   #1
pickels5980
Registered User
 
Join Date: Jan 2003
Posts: 17
Default capturing two or more keypresses

Hi! I have a code that captures keypresses. It works ok if only one key is pressed but I need to capture multiple keypresses. Like ctrl + shift.

I tried using a AND (&&) statement on the if then else statement but it doesn't work. Here's my code:
PHP Code:
_root.createEmptyMovieClip("mc1"1);
with(_root.mc1)
{
    
someListener = new Object();
    
someListener.onKeyDown = function () 
    {
        if(
Key.isDown(Key.UP)) 
        {
            
trace("up");
        } 
        else if (
Key.isDown(Key.DOWN)) 
        {
            
trace("down");
        }
        else if (
Key.isDown(Key.CONTROL) && Key.isDown(Key.UP))
        {
            
trace("Up and Down");
        }
    }
    
Key.addListener(someListener);

I would greatly appreciate some help on this. Thanks in advance.

Last edited by CyanBlue; 09-27-2004 at 03:45 PM.. Reason: PHP tag is applied
pickels5980 is offline   Reply With Quote
Old 05-20-2003, 07:45 AM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 25,331
Default

Howdy...

Here you go...
ActionScript Code:
_root.createEmptyMovieClip("mc1", 1); someListener = new Object(); someListener.onKeyDown = function() {     if (Key.isDown(40))     {         if (Key.isDown(17))         {             trace("Down and Control");         }         else         {             trace("DOWN");         }     }         if (Key.isDown(38))     {         if (Key.isDown(17))         {             trace("Up and Control");         }         else         {             trace("UP");         }     } }; Key.addListener(someListener);
Just for your information, you don't have to put the key listener into the movieclip as you did...

Please use code formatting so that the code could be more readable...


Keyword: ctrl up down cbctrl cbup cbdown multiplekey cbmultiplekey
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-20-2003, 08:05 AM   #3
arun_joy
Registered User
 
Join Date: Mar 2003
Location: bangalore
Posts: 23
Cool what about Alt Key ?

Is there any way to trap alt key in flash.
arun_joy is offline   Reply With Quote
Old 05-20-2003, 08:49 AM   #4
pickels5980
Registered User
 
Join Date: Jan 2003
Posts: 17
Smile

It works! Thanks a lot!
pickels5980 is offline   Reply With Quote
Old 05-20-2003, 01:19 PM   #5
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: EGYPT
Posts: 12,439
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default Re: what about Alt Key ?

Quote:
Originally posted by arun_joy
Is there any way to trap alt key in flash.
ActionScript Code:
_root.onEnterFrame = function() {     if (Key.isDown(18)) { // Alt = 18         trace("ALT heheheheeeeeeeeee");     } };
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 05-21-2003, 04:52 AM   #6
arun_joy
Registered User
 
Join Date: Mar 2003
Location: bangalore
Posts: 23
Wink thanks

actually what i was searching is to disable the user from pressing Alt+F4. is there any way to do tat ?
arun_joy is offline   Reply With Quote
Old 05-21-2003, 05:03 AM   #7
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 25,331
Default

I am not 100% sure, but I think there are some projector tools that supports the functionality... Check out SWf Studio or ScreenWeaver and others if you are looking for the projector solution...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-21-2003, 06:37 AM   #8
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: EGYPT
Posts: 12,439
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

I don't think so Cyan, it's a system matter not a flash matter, so, the system will over write yours
same like the fscommand(toggle.....
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 05-21-2003, 09:04 AM   #9
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: EGYPT
Posts: 12,439
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

or see this thread:
http://www.actionscript.org/forums/s...threadid=15167
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 05-21-2003, 10:17 AM   #10
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 25,331
Default

Oh... All I was saying meant to search those projector tools...
I know that you can trap the key combination such as Alt-F4 in Director with the support of some Xtras... So, basically that key trapping has been done in C/C++... That means the projector tools should be able to have that sort of options... If those projector tools do not support that functionality, that just means that the company is not thinking of that feature or they are just plain lazy...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:27 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.