Can't use the new keyboard component (from Psychtoolbox)

Sorry that psychtoolbox lib wasn’t included in the win64 standalone. It is in the next release (3.1.1).

The idea of waitRelease is that, in a scenario where you want a duration to be reported we have to decide what to do about keys that are still currently held down (the press is incomplete - we don’t yet have all the data for those).

With waitRelease=true only key presses that have been completed are returned, so all are guaranteed to have a duration value, whereas with waitRelease=False a key that is still held down will be reported but simply won’t have a duration value.

from psychopy import visual, event, core
from psychopy.hardware import keyboard


kb = keyboard.Keyboard()

win = visual.Window()
msg = visual.TextStim(win, 'Using WaitKeys()\n\nPress a key!', wrapWidth=1.5)
msg.setAutoDraw(True)
instruct = visual.TextStim(win, pos=(0,-0.8),
    text='Press Esc to move on (to test getKeys)', wrapWidth=1.5)
instruct.setAutoDraw(True)
win.flip()

msg.text = 'Press and hold a key, or press one quickly'
instruct.text='Press Esc to finish'
while continuing:
    core.wait(0.5)
    
    complKeys = kb.getKeys(waitRelease=True)  # don't clear - keep for next
    remainingKeys = kb.getKeys(waitRelease=False)
    txt = ''
    
    if complKeys:
        txt += 'Complete presses:\n'
        for key in complKeys:
            txt += ('key: {}, RT={}, duration={}\n'
                    .format(key.name, key.rt, key.duration))
    if remainingKeys:
        txt += '\nKeys still down:\n'
        for key in remainingKeys:
            print(dir(key))
            txt += ('key: {}, RT={}, duration={}\n'
                    .format(key.name, key.rt, key.duration))
            if key.name=='escape':
                continuing = False
    if txt:
        msg.text = txt

    win.flip()

Actually though I think the timing looks wrong here! I’m getting negative durations!! :-/