• Welcome to the PopMalt Forums! Whether you're new to forums or a veteran, welcome to our humble home on the web! We're a 20-year old forum community with thousands of discussions on entertainment, lifestyle, leisure, and more.

    Our rules are simple. Be nice and don't spam. Registration is free, so what are you waiting for? Join today!.

on keypress question

Mirage

Secret Agent
Staff member
V.I.P.
Does anybody know if there is a way to set an "on keypress" that will look for any key pressed except for a specified key?

Like on (!keypress "a") or something. I know that doesn't work though but does anybody know how to do that or if it is even possible?
 

Doc

Trust me, I'm The Doctor.
V.I.P.
Actionscript. There's a way, I know for sure. Unfortunately, I can't remember ATM and I don't know CS3.
 

Mr_Snipes

Registered Member
I guess I should look in the forum. ActionScriping I do not know. Try doing a search for ActionScripting and keypresses.
 

Mirage

Secret Agent
Staff member
V.I.P.
I guess I should look in the forum. ActionScriping I do not know. Try doing a search for ActionScripting and keypresses.
Sorry, I assumed most people would see what forum it was in before replying. :D

And yeah I'm sure it is possible. The other alternative is to create 100 or so if statements for every key on the keyboard except for the one that I want pressed.... but that would be a nightmare.

There has got to be an easier way but I searched for hours on Google and couldn't make sense of anything I found. :shake:
 

Mirage

Secret Agent
Staff member
V.I.P.
I actually was reading that page the day I made this thread.. lol! It confused me like crazy..

All I want to do is basically create an if statement for if "any key besides x" is pressed, do whatever. Is that possible?

I know how to do if X is pressed, but what about the opposite?
 

Mr_Snipes

Registered Member
Well if you know how to make it so that when "X" is pressed it, you can have it do something. Then create that statement that you would use to have the computer do something if "X" is pressed, but don't put anything for it to do, and then put an else statement after it, and in there put what you want the computer to do for all other keypresses.

That should solve the problem, because when "X" is pressed, the computer will find the empty if statement for that keypress, but when any other key is pressed it will execute the else statement and follow the commands inside that statement.

Does that help?
 
Last edited:

Mirage

Secret Agent
Staff member
V.I.P.
I wonder if the else idea will work. Didn't even think of that. I will try it and post my results. :)

EDIT: Ok that does not work. The actionscript for detecting a keypress is:

on (keypress "key")

not if (keypress, etc, so else does not apply here. Can you think of a way around it?
 

Mr_Snipes

Registered Member
Please post here the exact code that you use to get actionscripting to recognize that the "X" key has been pressed.
 
Top