If you want to monitor multiple keys on the keyboard to see if sprites should move or be turned (or whatever), you have a couple of options.
1)For a given sprite, you could have a forever loop that contains "If" <KeyPressed> statements to check the keys that you care about.
2)You could have multiple scripts that start with "Wait Until" <KeyPressed> that would check each key separately and would set a variable or send a broadcast.
How about:
Sensing for "Any Key" would be a nice way to trigger looking at several keys in one script. The script could start with "Wait Until" <Any Key Pressed>, then go on to find out which one(s).
Offline
Interesting idea...I think it could work well, although it would also need a way of ckecking for only previously referred to keys, so that if keys were accidentally pressed, it wouldn't scan for them too and thus slow down the game interface, if that makes sense...
Offline
If you do a wait until any-key, then you need some way of recording which key that was for subsequent tests, since the key might no longer be pressed by the time the test is made. This complicates scripts, rather than simplifying them.
Offline
The key wouldn't go "unpressed" quicker than the program could catch it unless the script had wait statements or was really, really long. You could verify this if in doubt, by setting up a Forever If < "n" Keypressed> followed by an If <"n" Keypressed> (Show something), Else (Show some other thing) statement. See if you can press your chosen key and let go so quickly that you don't get "caught".
In any case, what I originally described was a way to avoid constantly checking keys if nothing was being pressed. The thought was for something like a game control function where the arrow keys might be used to turn a character, in this case, the user would be holding the key to execute a turn.
In addition to the use originally described, I can also imagine using the proposed function to ask the user for input:
Press "1" (player) or "2" (player)
If they press any other key, you could now briefly display an error message: "Please Select 1 or 2 player". This would be a nice "professional" touch.
The function would also be nice for the old "Press Any Key to Continue" thing.
Offline
If you have to compare the pressed key against several choices and have several other scripts running, it is actually fairly easy for a scheduling break to occur between the key detection and seeing what key was pressed. This sor tof timing error is very difficult to debug, and scratch should not be set up to make such race conditions common.
Offline