how do you check if any key is down
if (Greenfoot.getKey() != null) { //a key is pressed; }
if (Greenfoot.isKeyDown("a") // code for 'a' down if (Greenfoot.isKeyDown("b") // code for 'b' down // etc.
if (Greenfoot.getKey() != null)
if (Greenfoot.getKey() != null) { //a key is pressed; }
String keys = "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_-+={[}]|\\<,>.?/`~"; String[] specialKeys = { "enter", "escape", "space", "backspace", "tab", "shift", "control", "up", "down", "left", "right", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" }; int i = 0; for (i=0; i<keys.length(); i++) if (Greenfoot.isKeyDown(keys.substring(i, i+1))) break; boolean keyFoundDown = i < keys.length(); if (!keyFoundDown) { for (i=0; i<specialKeys.length; i++) if (Greenfoot.isKeyDown(specialKeys[i])) break; keyFoundDown = i < specialKeys.length; } if (keyFoundDown) // do whatever.