Game Development Community

Capturing Keyboard Bindings in Engine

by Matthew Harris · in Torque Game Engine · 02/23/2004 (12:22 pm) · 4 replies

I have looked over the ActionMap code a bit. I am a little confused how I can get a key binding in code. Lets say the key was 'W'. Then from that how would I tell if the key is pressed or released. Sorry if this is real simple, having some trouble with it. To make it more clear I don't want to just see if 'W' is pressed.. This key is not hardcoded in the engine. I want to read the binding from the actionMap in the script and use that for pressed/released. Thanks again... enough rambling =)

-Matthew Harris

#1
02/23/2004 (10:18 pm)
Check out the code behind the options screen - it messes with keybindings in this way. Also check out default.binds.cs.
#2
02/24/2004 (2:02 pm)
In script, you'll want something like the following to add the binding:
GlobalActionMap.bind(keyboard, "w", myFunction);

Then define the function like so:
function myFunction(%make)
{
    if(%make)
    {
        // Key down
    }
    else
    {
        // Key up
    }
}

-ner
#3
02/26/2004 (1:27 pm)
No, i want to do this in code..
#4
02/26/2004 (1:37 pm)
If you want to cut the console out of the picture you're going to have a much harder time of it.

Have you looked at Moves?