Description of the problem:
I have trouble making moving object using psychoJS.
What I want to make is an object (e.g., circle) that is movable using keyboard.
I have done this in the offline experiment using pyglet library as below:
import pyglet
from pyglet.win import key
keyState=key.KeyStateHandler()
win.winHandle.push_handlers(keyState)
if keyState[key.RIGHT]:
position+=speed
elif keyState[key.LEFT]:
position-=speed
However, it seems that psychoJS does not contain libraries similar to pyglet
I tried to make code in javascript that can receive current Keyboard state, however, I was not successful until now.
(getKeys in the keyboard library seems to detect keyboard input but it seems that it does not detect
continuous keyboard press inputâŚ)
Youâd be better off going that route and seeing how far the auto translate option to JavaScript gets you. It wonât be able to do much with pyglet calls.
Actually, I failed to implement smoothly moving object using current psychoJS keyboard.
Therefore, I tried to use keyboardJS library of the javascript by importing in javascript code as beloe:
Since I couldnât get the keyboard work online, I was about to convert the .py file to .exe and send it out to participants like that, instead of using psychoJs.
This keyboardJS library is supposed to be installed by the user, right? I downloaded it and placed inside the âlibâ folder. However when you sync the library wonât be uploaded to gitlab. You need to fix this by commenting them out in the .gitignore (found in your project repository) then it can be uploaded.
However, even after uploading it, the library canât be loaded to Pavlovia. I think Pavlovia only allows the usage of some specific libraries.