Cheers @simonc8 !
The Trinket implementation of Processing + Python is based on Skulpt + ProcessingJS
And ProcessingJS is kind of a zombie, unfortunately (GitHub - processing-js/processing-js: A port of the Processing visualization language to JavaScript.) so I couldn’t find any documentation about keyCode.
Maybe you could try pyp5js: drawing with Python 3 | pyp5js which is a work in progress, but at least you can open an issue if it doesn’t work…
And there are other options to explore, like http://p5py.com (Brython based)
More options at Python + Processing table