Measuring key lift time relative to stimulus onset

As a follow up, I have now found a solution to this. In my routine I also had a keyboard component which was conflicting in some way with the keyboard set up in my code. Once I deleted my keyboard component, the above code worked!

However, if key presses remotely overlap, they do not get a duration: