Alice Community  

Go Back   Alice Community > Alice 2 > Suggestion Box

Thread Tools Display Modes
Keyboard key variables?
Senior Member
zero00's Avatar
Status: Offline
Posts: 300
Join Date: Oct 2009
Default 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?

==============Some of my Games and Ideas===========

Sky Warrior:
Health Bars:
Sky Warrior: Dual Force:

Want to make your own space game?
Reply With Quote
Senior Member
room14's Avatar
Status: Offline
Posts: 549
Join Date: Nov 2009
Location: Auckland New Zealand
Default 11-17-2011, 03:31 AM

i heard, using scripting you can.

Reply With Quote
Senior Member
sfunk's Avatar
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 11-17-2011, 08:53 AM

Originally Posted by room14 View Post
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

If you are stuck on a project, check out the tutorials I made here at this link:

There are lots of tutorials on it so far, including some youtube videos, check it out


Go to my youtube channel to check out my alice 2.2 tutorials I have there..
Reply With Quote
Mr Kidnapper
Senior Member
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 11-17-2011, 09:32 PM

Use the ASCII key table.
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.
Reply With Quote
More keys for When "<key> is typed" event
Senior Member
aikmin's Avatar
Status: Offline
Posts: 85
Join Date: Mar 2008
Default More keys for When "<key> is typed" event - 11-18-2013, 12:08 AM

Edit your \Required\resources\common\ file.

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

Add the items/keys you want.

If you are not sure of the keyCode, refer to

Repeat for (if needed):
["edu.cmu.cs.stage3.alice.core.behavior.KeyIsPr esse dBehavior",
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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