Game Development Community

Binding number keys

by USC - IMD student 5 · in Torque Game Builder · 11/07/2007 (10:51 am) · 4 replies

In my behavior I've bound keys with no problem with something like:

%template.addBehaviorField(weaponOneKey, "Key to bind to weapon 1", keybind, "keyboard A");
...which gives me a nice drop down menu of all possible keybindings. It also even gives joystick possibilities. But it doesn't give the simple number keys (0-9). It does give the numpad keys, and all letters of course. How can I bind the number keys?

#1
11/07/2007 (12:08 pm)
I figured it out - Just have to manually bind the keys in the onBehaviorAdd function.

moveMap.bindObj("keyboard", "1", "function1", %this);
      moveMap.bindObj("keyboard", "2", "function2", %this);
      moveMap.bindObj("keyboard", "3", "function3", %this);

The above code will bind the "1" key to function1, etc.
#2
05/09/2012 (12:11 pm)
Thanks for figuring this out, I'm not entirely sure why the number keys aren't present in the dropdown and why they're not treated the same as every other key on the keyboard.
#3
05/11/2012 (12:13 pm)
@Chris - I wasn't aware of this either, since I've never needed to bind a keyboard number. I'll have a look at resolving this for a future release.
#4
05/11/2012 (12:44 pm)
Excellent, thanks Michael. I also just realized this thread was from 2007 so thanks goes to Google as well I guess.

:)