I'm doing a minigame that while the shift key is pressed down the image of an actor is changed...
I tried to use the "isKeyDown()" function, but it don't get the shift key.
Could someone help me?
As far as I can see the shift key isn't currently mapped to anything with Greenfoot and therefore won't work with isKeyDown(). The simplest solution would simply be to use another key - is there any reason why you want to use the shift key in particular?
well, I'm doing something like "organ hero", so, for each musical note I have one key in the keyboard.
For example, the G note (Sol) will be the "m" key;
When come G# note, the key must be the "M" key, and, while the shift key is pressed down, my "note sphere" (local where the key must be pressed) whill change color.
* The game whithout shift key down.
img1
* The game when the shift key pressed down.
Img2
I tried to do this whith java Key Listener, but it seems so hard to me now...
I was just searching out basically the same thing. I was hoping to be able to check the status of Shift (or Ctrl or Alt) while a key (a Function key, in my case) was pressed. It would have been nice to use the same function key for small steps (without the extra key) and large steps (with the extra key). :+(
This is what the greenfoot api says it supports:
-"a", "b", .., "z" (alphabetical keys), "0".."9" (digits), most punctuation marks. getKey() also returns uppercase characters when appropriate.
-"up", "down", "left", "right" (the cursor keys)
-"enter", "space", "tab", "escape", "backspace"
-"F1", "F2", .., "F12" (the function keys)
http://www.greenfoot.org/doc/javadoc/greenfoot/Greenfoot.html
I was just searching out basically the same thing. I was hoping to be able to check the status of Shift (or Ctrl or Alt) while a key (a Function key, in my case) was pressed. It would have been nice to use the same function key for small steps (without the extra key) and large steps (with the extra key). :+(
As above, the function keys are mapped and can be checked with "F1" through to "F12".
As said already it's probably best to just use another key rather than trying to fudge the shift key - you could use, space, a punctuation character (full stop, single apostrophe?) or one of the arrow keys perhaps?
After looking at whether it'd be worth adding shift to Greenfoot's recognised keys (and talking about it with Davin) it seemed to be a trivial change, so I've added support for shift and control keys to the codebase. All going well (i.e. if a problem isn't found with it in the meantime!) this should appear in some future release.