I’m curious about why keyCode doesn’t seem to recognise keypresses when you import processing using an alias. I am using trinket, so that may be an issue.
With this simple code
from processing import *
def keyPressed():
print(keyCode)
run()
I can derive the keyCode value for any key I press. But if I change the import style:
import processing as p
def keyPressed():
print(p.keyCode)
p.run()
the code runs but it prints the word unknown surrounded by less than and greater than signs
whatever key I press.
Do you know if there is a way to use the processing library with Python Idle? If I import processing it says ‘No module named processing’ so I suppose it needs installing, but using pip install processing doesn’t work. Do I need a different install command?
Processing is a Java library; hence it’s not available via pip. You could use py5 instead (pip install py5). Note that you’ll need to have Java installed on your computer.