Caps locks button is not working

Hello,

Has anyone had the issue using the keyboard where all of the buttons work except the caps lock button? I am trying to collect responses via caps lock, but the button is not responsive. I tried out the demo where it tells me which key I press and it returns ‘capslock’ but when I try to collect a response in my own task, it does not work. Thoughts?

Hi,

Please could you share the code snippets where you collect the response? then we can check it out more.

Thanks,
Becca

Sure thing, here it is. Any button I put in place of the capslock button works. Thanks for taking a look!

get_selection = False
while get_selection == False:
    
    key = kb.getKeys()
    
    if 'return' in key and select_feedback_to_press == 1:   # correct
        feedback_to_press_outcome = 'correct'
        quiz_and_attention_check_fails = quiz_and_attention_check_fails
        break

    elif 'capslock' in key and select_feedback_to_press == 1:   # incorrect
        feedback_to_press_outcome = 'incorrect'
        quiz_and_attention_check_fails = quiz_and_attention_check_fails + 1
        break

    select_feedback_to_press_slide.draw()
    win.flip()

kb.clearEvents()

Hey,

to check - have you tried giving getKeys a keyList that includes capslock?

Also to check, I don’t suppose you are using a mac?

Looking at the keyNames in the keyboard class for mac it doesn’t look like ‘capslock’ is listed so that could be a problem (PsychoPy3\lib\site-packages\psychopy\hardware\keyboard.oy)

Thanks,
Becca

I am using a mac actually so that may be the issue. I cannot find the path you are referring to. Is it under demos?

Aha! so, for future, in mac the path will be a little diff as it is under package contents (to look at package content on mac you can right click the app the view content I think, in there you are looking for a folder called hardware and the keyboard.py file contains the keyboard class)

@TParsons is this an issue on git? capslock is listed in the windows and linux keys but not mac :slight_smile:

Thanks,
Becca

Got, it. Thanks so much for your help!

I’m not super familiar with Mac stuff, but I’m guessing the reason is that it has the same key code as LShift:

Not sure why it works like that, or how Mac OS differentiates between them, but I’ll look into it and whether it’s possible to differentiate between capslock and lshift in PsychoPy