Alice Community

Alice Community (
-   Suggestion Box (
-   -   Keyboard key variables? (

zero00 11-17-2011 03:21 AM

Keyboard key variables?
Is it possible to add a "key" variable to Alice, and to modify the [I]When a key is typed[/I] 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?

room14 11-17-2011 03:31 AM

i heard, using scripting you can.

sfunk 11-17-2011 08:53 AM

[QUOTE=room14;43590]i heard, using scripting you can.[/QUOTE]

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 [URL=""]ASCII key table[/URL].
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.

aikmin 11-18-2013 12:08 AM

More keys for When "<key> is typed" event
Edit your \Required\resources\common\ 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 [url][/url]

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

All times are GMT -5. The time now is 05:31 AM.

Copyright ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.