PsychoPy script not registering keypresses in Ubuntu

Hi everyone. To preface, my python version is v3.8.10, pyglet version is 1.4.11, and psychopy is 2023.2.3. I am working on an Ubuntu release 20.04. I am having trouble with a script that is not registering keypresses; code below.

instructions block

instructions = [
“Welcome to the task. Press the right arrow key to navigate to the next page.”,
“Page 2.”,
“Page 3”
]
current_page = 0
while current_page < len(instructions):
text_instruction = visual.TextStim(win, text=instructions[current_page], color=‘white’, height=25)
text_instruction.draw()
win.flip()
keys = event.waitKeys(keyList=[‘right’, ‘left’])
if ‘right’ in keys:
current_page += 1
elif ‘left’ in keys and current_page > 0:
current_page -= 1

This instructions block is the first thing that the subject interacts with. However, the task is not progressing when the relevant keys are pressed. I have tried changing ‘right’ and ‘left’ to ‘r’ and ‘l’ in case it’s a key mapping problem, but had no success. Could this be a problem with the event.waitKeys() function? Are there other routes that I should try?

There are no errors in terminal when I run the script. The script works well in Windows and macOS. I’m happy to provide any additional information.