Player Y location messed up (p5.js)

I have a resizable canvas in which a player is drawn. For some reason, the player will go off screen if the screen is too tall. This usually occurs in fullscreen mode, where the game will mostly be played. I’ve tried to change how it’s calculated based on mx and my, but nothing seems to work.

Fullscreen, where the bug is happening: https://editor.p5js.org/Voxel_/full/61_2FX_-4

Code (it works fine in the preview canvas): https://editor.p5js.org/Voxel_/sketches/61_2FX_-4