psychopy.org | Reference | Downloads | Github

Keyboard input to move selecter on rating scale not detected

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

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()

Thank you for your answer.
Ideally I would like to stick with the RatingScale, rather than switching to the slider, since it makes it easy for me to record the reaction time.

I have already set my window to fullscreen (fullscr = true).

I am further puzzled about this issue.
I have added a screen displaying instructions to the participant, and to move on from the instruction, the participant needs to press any key. If a letter key is pressed it is registered, and program continues, but the letter they types will also be added to the code in the psychopy coder window (at the location I was last writing).
The same thing happens when the participant click ‘A’ or ‘L’ (which are used to move the ratingsscale), except they only occur in the code, but does not work on the rating-scale, untill the window has been clicked with the mouse (still only for first ratings-scale out of the loop).

Anybody recognize this issue?
Linea