on keypress question

Mirage

Administrator
Staff member
V.I.P.
#1
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.
#3
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
#4
I guess I should look in the forum. ActionScriping I do not know. Try doing a search for ActionScripting and keypresses.
 

Mirage

Administrator
Staff member
V.I.P.
#5
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

Administrator
Staff member
V.I.P.
#7
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
#8
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

Administrator
Staff member
V.I.P.
#9
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?