How to keep rotating line when holding the key

URL of experiment:

Description of the problem:

Hello, I am working on an adjustment task in which participants must rotate the line till it matches the orientation they previously saw. They have to press keys until they find a match, which takes a long time. Could you kindly assist me in making it continuous? ( keep rotating the line while holding the key). I can do it locally, but not online as packages do not work for JS. Many thanks.

Hi There,

You could try something like this but updating orientation if the space is pressed How can I save keypress duration in online experiments? - #2 by wakecarter

Hope this helps,
Becca

1 Like

Thank you Becca. I am not sure if I understand what should I do. My problem is similar to what was asked here (Faster rotation). @wakecarter suggested a solution based on what he did for the screen scale routine (Faster rotation - #8 by wakecarter) but I couldn’t figure it out how to do it.

keys = event.getKeys()
if len(keys):
    if t-oldt<.5:
        dscale=5*dbase
        oldt=t
    else:
        dscale=dbase
        oldt=t

This bit of code says that if you press a key faster than twice per second then you should change the size (or orientation) by 5 times as much as you should if you press keys slower.

This works with multiple key presses, not holding keys down.

1 Like

Aha OK - that was my mistake I thought it worked for pressing keys down.

In that case - detecting is a key is pressed down is a little verbose in psychoJS can you achieve what you want through a mouse press instead and using

if mouse.isPressedIn(COMPONENT NAME):

it will be much easier

1 Like

Here is an example of how that would work:

https://run.pavlovia.org/lpxrh6/method-of-adjustment/

files available here: Rebecca Hirst / method-of-adjustment · GitLab

1 Like

Thank you so much. It solved my problem.

Thanks for your reply!