Stage::isKeyPressed()
Returns true if the passed key is pressed.
Examples

import org.openpatch.scratch.*;
public class StageIsKeyPressed {
public StageIsKeyPressed() {
Stage myStage = new Stage(600, 240);
while (myStage.getTimer().forMillis(3000)) {
myStage.display("Space pressed? " + myStage.isKeyPressed(KeyCode.VK_SPACE));
}
myStage.exit();
}
public static void main(String[] args) {
new StageIsKeyPressed();
}
}
Syntax
Java
.isKeyPressed(keyCode)
Scratch
key [space v] pressed?
Parameters
Name | Data Type | Description |
---|---|---|
keyCode | int | A key code. You can use the enum KeyCode. For example KeyCode.VK_SPACE. |
Return
boolean