0

I am currently developing an app that is responsive to the viewer pressing keys on the keyboard. There are 36 different keys that will be pressed (a-z &0-9) when each key is pressed a specific colour will appear on screen, more than one key can be pressed at one time.

What is the code so that when you press the keys it triggers this?

The Guy with The Hat
  • 10,836
  • 8
  • 57
  • 75

1 Answers1

1

You need to keep track of which key presses you care about (in boolean variables or an array). In keyPressed(), set the corresponding boolean to true. In keyReleased(), set it to false. Then just check against those booleans in your draw() function to display the correct color.

More info can be found in the "detecting multiple key presses" section of this Processing tutorial: http://staticvoidgames.com/tutorials/intermediateConcepts/KeyboardInput.jsp

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107