Description of the problem: I want to get the screen size and output it to a csv file. Is it possible to achieve this with the code component?
Hello! yes you can do that by saving win.size - here is a demo that might help Pavlovia
Hey! Short answer: no. Longer answer, I happen to have been exploring this a bit (by examining whether window.innerWidth/innerHeight, screen.width/height, and devicePixelRatio could get us there). I haven’t found any reliable way to get the resolution in pixels nor the screen size in centimeters.
I can imagine a solution that uses @wakecarter’s screenscale experiment. The credit card has a standard size in cm. After the screenscale experiment you know the size of the credit card in PsychoJS height unit. You can also obtain the size of the window in PsychoJS height units, so then you could infer how large the screen is in cm. Note that this would be the size of the window, not of the screen. Some browsers, like iOS Safari, don’t easily allow the window to go fullscreen, so they still display an address bar on top.
Ah yes, if you need screen size that will have issues but I think for most people window size fulfils the requirements, and that is easy to access.