psychopy.org | Reference | Downloads | Github

Keyboard input to move selecter on rating scale not detected

#1

I have a likert-scale, where participants move the selecter rightwards and leftwards by clicking the ‘L’ key and ‘A’ key.
My issue is that the input is registered in the coder window(i.e. the ‘a’ or ‘l’ is added to my code), not in the experiment window, unless I click the experiment window with the mouse to set focus.
The scale appears within a loop, and it is only the first trial that presents the issue. After that, keyboard is registered and used to move the selecter on the scale without issue. I intend to run the experiment without the use of a mouse, so any help on how to solve this issue is greatly appreciated.
Is there a way I can force my system to set focus on the experiment-window when it opens?

Some info:
PsychoPy v. 3.1.0 (coder)
The issue is the same if using left/right arrow keys.
I believe I am using PyGame v. 1.9.4 for graphics (it seems to be my default)
Windows

#2

Hi @Linea, so you have to manually focus the window using the mouse? What happens when you set the window to fullscreen using the fullscr window param? By the way, the same thing can be achieved using the new Slider component. E.g., the following should work in Coder.

from __future__ import absolute_import, division
from psychopy import locale_setup, visual, core, event

win = visual.Window(
    size=(1024, 768), fullscr=False, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True, 
    units='height')

slider = visual.Slider(win=win, name='radio',
    size=(1.0, 0.1), pos=(0, -0.1),
    labels=['a','b','c','d','e'], ticks=(1, 2, 3, 4, 5),
    granularity=0, style=['rating'],
    color='LightGray', font='HelveticaBold',
    flip=False)

slider.reset()
slider.markerPos = 2
while True:
    keys = event.getKeys()
    if keys:
        if 'left' in keys:
            slider.markerPos -= 1
        if 'right' in keys:
            slider.markerPos += 1
    
    # check for quit (typically the Esc key)
    if "escape" in keys:
        core.quit()
    slider.draw()
    win.flip()


# make sure everything is closed down
thisExp.abort()  # or data files will save again on exit
win.close()
core.quit()