This content has been marked as final. Show 4 replies
Not sure if it matters, but a couple of your "end"s don't match your "on"s.
You have "on EnterFrame" ended by "end keyUp", and "on keyUp" ended by "end
keyDown". Probably doesn't matter. I always end every function with just
"end", so I don't think anything that comes after that makes any difference.
As for your other problem, it appears that you're executing the code
checking for CTRL, ALT, and SHIFT every single frame, instead of just when
the key is initially hit. You should add variables to make it only do these
calls once when you first hit the key, and reset only when the key is
released. So, for example:
if (_key.shiftDown = TRUE) then
if shiftHit = 0 then
shiftHit = 1
member("Character").text = string("Shift")
else shiftHit = 0
Do this for the CTRL/COMMAND and ALT/OPTION as well, and it should work
Thank you Mr. Hoffman for your noticing. No, the 'end' statements don't reallly matter. They are just helpful for navigation. I will be fixing it, however, because I've written some complex stuff and it helps keep me where I should be.
I am using the frame script because, from my experience anyway, I can not use keyPressed, keyUp or keyDown to detect the modifier keys. Therefore, I must check them as often as I can since I need them to activate immediately when they are struck.
I have been considering code that is similar to yours to 'deactivate' the shift key after another key had been pressed. It just handn't occurred to me yet. And, I'm still not a hundred percent on how I'd do it.
Thanks for your assistance.
Have a wonderful day.
> I have been considering code that is similar to yours to 'deactivate' the
> shift key after another key had been pressed. It just handn't occurred to
> yet. And, I'm still not a hundred percent on how I'd do it.
Well, don't just 'deactivate' it when another key is pressed. 'Deactivate'
it as soon as the program gets the message that it's down, otherwise you'll
end up with it calling the shift-announce every single frame that the key is
down instead of just once. In fact, I'd expect that you'd hear a stuttering
sound, like "Sh-sh-sh-sh-sh-sh-sh-shift", repeating the beginning over and
over until the key is released. Unless the voiceSpeak command just holds
off until whatever's in the cue is finished playing before doing the next
line, in which case it would instead just keep saying "Shift shift shift
shift shift" over and over until it ran out the cue, long after you release
the key. (Haven't used that function much, so I'm not sure which would
happen, but I'd assume it'd be one or the other.)
Anyhow, since the Shift, Ctrl, Alt (or Shift, Command, Option) keys don't
register keyUp and keyDown events like regular keys, you have to handle that
yourself, and using a variable for each of these keys like in my example
should do the trick. Consider yourself lucky. In other programming
languages I've used, I had to handle ALL the keys that way, since they
didn't have keyUp and keyDown functions at all.
Well, luckily, I am only detecting shifted characters. Anyway, yes, when a character is struck, I will change a variable like you suggested, which will 'turn off' the shift detection.
Thanks for the help.