PFont customFont;
void setup() {
size(400, 400);
background(220);
// Load a font that includes the necessary characters
customFont = createFont("Arial", 32);
textFont(customFont);
}
void draw() {
// This function is intentionally left empty
}
void keyPressed() {
// Display the key that was pressed on the background
background(220); // Clear the previous content on the background
textSize(32); // Set the text size
fill(0); // Set the text color to black
text("Key Pressed: " + key, 50, 50); // Display the key value on the canvas
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter