Game Development Community

If key is pressed...

by Tom Perry · in Torque Game Builder · 08/19/2005 (7:20 am) · 4 replies

Hiya
I got T2D a few days ago and love it. I have a question though and I couldn't find the anwser searching. Is there a comand to check to see if a key is being pressed? Thanks if you can help.

#1
08/19/2005 (9:14 am)
Welcome! :)
There's no built in function that will tell you if a key is currently being held down, but there's an easy workaround. The keybinding allows you to set one function to be called when the key is depressed, and another when it is released. Simply have the keydown function set a flag, and the keyup function unset said flag. You can then check for the flag's status to determine if the key is being pressed.
#2
08/19/2005 (9:16 am)
O yea lol, don't know why I didnt think of that! thanks a lot.
#3
08/19/2005 (10:16 am)
To be fair, I didn't think of it either, when I started off. Someone pointed me in the right direction early on. :)
#4
08/19/2005 (10:22 am)
Binding the down and up event commands can be very useful like that :)