View Full Version : Keyboard key variables?

11-17-2011, 03:21 AM
Is it possible to add a "key" variable to Alice, and to modify the When a key is typed events accordingly?

For example, "Key" = Spacebar
If "Key" is pressed, execute method.

This would make it easier for games to have keys that can be reassigned during play.

Also, can you add other keys like control, alt, shift, and the number pad buttons to the list of keys?

11-17-2011, 03:31 AM
i heard, using scripting you can.

11-17-2011, 08:53 AM
i heard, using scripting you can.

I think adding more keys, but not making keys variables, there is a cheap way to making keys a variable though, using boolean/number variables and if/else statements

Mr Kidnapper
11-17-2011, 09:32 PM
Use the ASCII key table (http://www.bbdsoft.com/ascii.html).
Alice detects keys as ASCII in decimals. What you can do is make a key map. Unfortunately, this method is expensive. I'm doing it now using purely booleans. Even in my boss rig, this is taking a very long time because Alice feels like rendering 127 nested if/else statements every time I make a change.

11-18-2013, 12:08 AM
Edit your \Required\resources\common\StandardResources.py file.

Find this section in the file:
["edu.cmu.cs.stage3.alice.core.behavior.KeyClickBeh avior",
java.awt.event.KeyEvent.VK_ENTER, ...

Add the items/keys you want.

If you are not sure of the keyCode, refer to http://docs.oracle.com/javase/7/docs.../KeyEvent.html

Repeat for (if needed):
["edu.cmu.cs.stage3.alice.core.behavior.KeyIsPresse dBehavior",