Key response not working

Hello, I am trying to collect a key response from either the caps lock button or the enter button. For some reason, the caps lock button is irresponsive, but the enter button is working properly. I have tried to use other buttons as well and they all work except the caps button. Whenever I press it to respond, nothing happens. Any thoughts would be appreciated!

while timer.getTime() < 1.5: 
    current_time = timer.getTime()
    key = kb.getKeys()
     
    if 'capslock' in key:
        draw_yes_screen = True
        draw_no_screen = False
        allow_work = True
        break

    elif 'return' in key:
        draw_no_screen = True
        draw_yes_screen = False
        allow_work = False
        break

If you run the demo “keyNameFinder”, does it still work when you press capslock? If not then it could be a problem with your keyboard / keyboard drivers, if it does still work then could you share the .psyexp file? At first glance the code you’ve posted looks fine