I am making a program that will have rectanglesin the shape of a piano. I wanted to write to the console when one key is pressed, but when I press a key, nothing happens. In the fxml I have each rectangle's onMouseClicked equal to #keyPressed, so it should activate the code.
@FXML
public void keyPressed(Event e) {
String keyPressed = ((Control)e.getSource()).getId();
System.out.println(keyPressed + " Key");
playNote(60, 1);
}
Rectangle code:
<Rectangle id="A0" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="336.0" onMouseClicked="#keyPressed" stroke="BLACK" strokeType="INSIDE" styleClass="whiteKey" width="37.0" />
I couldn't get the solution here to work. Thanks for your help.