Problem: I want to disable the default functionality of the ESC key in a Processing sketch that creates a G4P child window. The standard method of doing this is:
But this only works in the main window, not the child window. So I created an event handler for the child window and registered it. It works in the sense that it captures key presses in the child window, but pressing the ESC key in the child window still closes both windows. How can I prevent this from happening? Here’s the event handler:
public void keyCheck(PApplet applet, GWinData data, KeyEvent event) {
if (event.getAction() == event.PRESS) {
keyCode = event.getKeyCode();
println("keyCode = " + keyCode);
if (event.getKeyCode() == ESC) {
// Now do what?
}
}
}
Works for me too, except for the first “println()”. I had to add the “applet.” qualifier to it as well, otherwise it prints the last key pressed in the main window.