Do you want the sketch to expand itself to fullscreen, but keep its original aspect ratio, or for it to simply keep its size with any screen?
If you want the prior option, you can just put:
if (width > height) pg=createGraphics(height, height);
if (width < height) pg=createGraphics(width, width);
Then use what I did on
https://discourse.processing.org/t/solved-making-the-contents-of-a-frame-relative-to-its-size/3595/2