Minor Changes
-
#3708
a69d7ad7aca8a0b0d97c5893ab09a368bd9dda25Thanks @jodeleeuw! - Added a CSS style to jspsych.css that renders<kbd>elements (or any element with class "jspsych-key") as a visual keycap. Wrapping a key name in<kbd>inside a trial renders it as a keycap, e.g.Press <kbd>space</kbd> to continue. -
#3707
a9f454ee58fda69173dbaa1ecfa4aa7797920031Thanks @jodeleeuw! - Added the ability to measure how long a response key was held down. ThegetKeyboardResponse()method of the keyboard plugin API gains an optionalwait_for_key_releaseoption; when true, thecallback_functionfires at key release instead of key press, and its payload includes anrt_key_durationfield (the press-to-release duration in milliseconds) alongside the usualkeyandrt. The five*-keyboard-responseplugins (html, image, audio, video, canvas) expose a matchingwait_for_key_releasetrial parameter (default false) and record the newrt_key_durationdata field. The release is matched to the press by the physical key (KeyboardEvent.code), so changing the shift state while holding a key (which changese.key) does not prevent the release from being detected, and thekeyreported to the callback is always the value from the original keydown event. If the window loses focus while a key is held (ablurevent), the browser stops delivering the eventualkeyup; in that case the pending release is resolved withrt_key_duration: null(the hold duration cannot be measured) and the held-key state is cleared so it does not leak into the next trial.