respyra.core.events

Response collection and event logging helpers.

Thin wrappers around PsychoPy’s event module that standardise the return format and provide a simple event-log accumulator.

respyra.core.events.check_keys(key_list=None, clock=None)[source]

Non-blocking check for keypresses.

Parameters:
  • key_list (list of str or None) – Keys to listen for. None accepts any key.

  • clock (psychopy.core.Clock or None) – If provided, return reaction times relative to this clock.

Returns:

Each element is (key_name, timestamp). The list is empty if nothing was pressed. When clock is None the timestamp comes from PsychoPy’s default monotonic clock.

Return type:

list of (str, float)

respyra.core.events.wait_for_key(key_list=None, clock=None, max_wait=inf)[source]

Block until a key is pressed (or max_wait seconds elapse).

Parameters:
  • key_list (list of str or None) – Acceptable keys. None accepts any key.

  • clock (psychopy.core.Clock or None) – Clock for reaction-time stamping.

  • max_wait (float) – Maximum seconds to wait. Defaults to infinity.

Returns:

(key_name, timestamp) for the first key pressed, or None if max_wait elapsed with no response.

Return type:

tuple of (str, float) or None

respyra.core.events.record_event(event_log, event_type, timestamp, **data)[source]

Append a timestamped event dict to event_log.

Parameters:
  • event_log (list) – Mutable list that accumulates event records.

  • event_type (str) – Label for this event (e.g. 'trial_start', 'response').

  • timestamp (float) – Time of the event (typically from a core.Clock).

  • **data – Arbitrary extra fields merged into the record.