This is a code snippet for python mode of Processing. The purpose of this code is to update a variable when a key is pressed. Processing has a variable called keyPressed which is True if a key is pressed. The identity of the key that is pressed is saved as a string in the variable named key.
if keyPressed:
if key == "a":
a += 0.1
elif key == "s":
a -= 0.1
elif key == "q":
q += 1
elif key == "w":
q -= 1
elif key == "z":
z += 3
elif key == "x":
z -= 3
Is this just the best way to write this, or is there a better way? If not, what if there were 100 keys each with a different variable to tweak?